cURL to Swift
Paste a curl command and get Swift code using URLSession — or pick any other language.
Paste a curl command above to generate code
How curl maps to Swift (URLSession)
- →Uses URLSession with async/await (iOS 15+, macOS 12+).
- →Headers are set with setValue(_:forHTTPHeaderField:), the body as UTF-8 Data.
- →Calling plain http:// URLs from an app needs an App Transport Security exception.
Frequently asked
How do I convert curl to Swift?
Paste the command and pick Swift (URLSession). You get a URLRequest with the method, headers and body, sent with try await URLSession.shared.data(for:).
Why does my request fail with an ATS error?
App Transport Security blocks plain HTTP by default. Use https, or add an exception for that domain in Info.plist.