Paste a curl command (for example one copied from your browser’s dev tools or from API docs) and get the equivalent Swift code with URLSession, using async/await or a completion handler.
cURL command
Swift code
The conversion happens in your browser: the command (and any keys or tokens in it) is never sent to any server.
What it understands
- The method (
-X), headers (-H), cookies (-b) and user agent (-A). - Bodies sent with
-d,--data-raw,--data-binaryand--json, with optional JSON pretty-printing. - Basic authentication with
-u. - Options that make no sense on iOS, like
-kor--compressed, are skipped with an explanation.
Before you ship the code
- Never leave tokens or API keys hard-coded: keep them in the Keychain or get them from your own backend.
- Plain
http://URLs are blocked by App Transport Security unless you add an exception. - Check the status code: URLSession does not throw on a 404 or 500.
Frequently asked questions
Is my command sent to a server?
No. The conversion runs in your browser, so tokens in the command stay on your computer.
async/await or completion handler?
Use async/await if your app targets iOS 15 or later; the completion handler version works on any iOS version.
¿Prefieres español? Esta herramienta en español.