JSON to cURL Generator
About this tool
Turn a JSON body and an endpoint into a cURL command. Either paste a plain
JSON value to use it as the body, or wrap it as
{"headers": {…}, "body": …} to include request headers.
How to use
- Enter the request URL and pick the HTTP method.
-
Paste JSON. With a
headersorbodykey it is read as a request object; otherwise the whole value becomes the body. - Copy the generated command and run it in a terminal.
Example
URL: https://api.example.com/users
Method: POST
JSON:
{
"headers": { "Content-Type": "application/json" },
"body": { "name": "barekit" }
}
Generated:
curl -X POST 'https://api.example.com/users' \
-H 'Content-Type: application/json' \
--data-raw '{"name":"barekit"}'
What the generated command does
-
The URL and every argument are single-quoted, with embedded single
quotes escaped as
'"'"', so the command survives a POSIX shell. -
Headers become
-H 'Name: value', in the order they appear in your JSON, with the name spelled exactly as you typed it. -
The body is serialised with
JSON.stringifyand passed through--data-raw, which sends it without reading a file and without processing@prefixes.
Limits
- The body is re-serialised, so your original indentation, key spacing and number formatting are lost. Numbers beyond 253 also lose precision, as with any JSON parse in JavaScript.
- Only JSON bodies are supported. Multipart forms, raw text and binary uploads need a hand-written command.
- Cookies, authentication helpers and redirect flags are not added; paste them into the command afterwards.
-
The output is POSIX shell syntax. Windows
cmdneeds different quoting.
FAQ
When is the JSON treated as a request object?
When it is an object containing a headers or
body key. Anything else — an array, a string, a number, or
an object without those keys — is used directly as the body.
Why does the command use --data-raw?
It sends the string exactly as given. With -d @file, curl
would read a file instead, and a leading @ would be
interpreted specially.
Can I send a GET request with a body?
The command is generated, but the server may ignore the body. Most servers do.
Is my data uploaded?
No. The command is assembled in the page from the JSON you paste.