---
title: formatted()
framework: foundation
role: symbol
role_heading: Instance Method
path: foundation/url/formatted()
---

# formatted()

Formats the URL using a default format style.

## Declaration

```swift
func formatted() -> String
```

## Return Value

Return Value A string representation of the URL, formatted according to the default format style.

## Discussion

Discussion Use this method to create a string representation of a URL using the default URL.FormatStyle configuration. As seen in the following example, the default style creates a string with the scheme, host, and path, but not the port or query. let url = URL(string:"https://www.example.com:8080/path/to/endpoint?key=value")! let formatted = url.formatted() // "https://www.example.com/path/to/endpoint" To customize formatting of the URL, use formatted(_:), passing in a customized URL.FormatStyle.

## See Also

### Formatting a URL

- [formatted(_:)](foundation/url/formatted(_:).md)
- [URL.FormatStyle](foundation/url/formatstyle.md)
