cURL to Swift
Paste a curl command and get equivalent Swift URLSession code, with headers, JSON body, cookies, and auth already translated.
Use the cURL to Swift
curl Command
Swift (URLSession)
Copied to clipboard.
Summary
Paste a curl command and get equivalent Swift URLSession code, with headers, JSON body, cookies, and auth already translated.
How it works
- Paste a curl command, including one copied from a browser devtools network tab.
- The parser tokenizes the command, honoring quotes and backslash line continuations.
- Flags such as -X, -H, -d, -b, -u, -F, and -G are mapped to URLRequest and URLSession equivalents.
- A JSON body is detected automatically and rendered as a Swift dictionary encoded with JSONSerialization.
- The generated Swift code appears in the output box, ready to copy into a project.
Use cases
- Turn a "Copy as cURL" request from browser devtools into a Swift network call.
- Reproduce an API call from documentation or a support ticket in an iOS app.
- Convert a curl example from a README into a starting point for a URLSession client.
- Debug an API integration by replaying the exact request curl sent, from Swift.
- Translate a webhook test command into a repeatable Swift snippet.
- Build a quick prototype around a request captured from a mobile app proxy.
Frequently Asked Questions
Last updated: 2026-09-19 ·
Reviewed by Nham Vu