---
title: query
framework: foundation
role: symbol
role_heading: Instance Property
path: foundation/url/query
---

# query

The query of the URL if the URL conforms to RFC 3986; otherwise, nil.

## Declaration

```swift
var query: String? { get }
```

## Discussion

Discussion note: This function resolves against the base URL. New code should use query(percentEncoded:) instead of this property.

## See Also

### Accessing the parts of a URL

- [fragment(percentEncoded:)](foundation/url/fragment(percentencoded:).md)
- [fragment](foundation/url/fragment.md)
- [host(percentEncoded:)](foundation/url/host(percentencoded:).md)
- [host](foundation/url/host.md)
- [lastPathComponent](foundation/url/lastpathcomponent.md)
- [path(percentEncoded:)](foundation/url/path(percentencoded:).md)
- [path](foundation/url/path.md)
- [password(percentEncoded:)](foundation/url/password(percentencoded:).md)
- [password](foundation/url/password.md)
- [pathComponents](foundation/url/pathcomponents.md)
- [pathExtension](foundation/url/pathextension.md)
- [port](foundation/url/port.md)
- [query(percentEncoded:)](foundation/url/query(percentencoded:).md)
- [scheme](foundation/url/scheme.md)
- [user(percentEncoded:)](foundation/url/user(percentencoded:).md)
