Developer tool

Create API Request Code — cURL & Fetch

Describe a request and copy code for your terminal or JavaScript project; this page does not send it.

Runs in your browser. No upload.

This tool builds code only. It does not send a request.

Browser CORS and server rules can block a request you run elsewhere.

No network request was sent.

About this tool

Create API Request Code — cURL & Fetch made simple.

Generated examples are local text only. Browser CORS, authentication, server rules and network access may affect a request you run elsewhere. Do not paste secrets into shared devices.

Guide

Using Create API Request Code — cURL & Fetch

The API Request Builder writes the code for an HTTP request so you can copy it. You choose a method, type a URL, add headers as JSON and an optional body, and pick cURL or JavaScript Fetch. The page only builds the text. It never sends the request, so you will not see a response, and it does not check whether the address or the server exists.

How to use it

  1. Pick an HTTP method and type a full http or https URL.
  2. Choose cURL or JavaScript Fetch as the output format.
  3. Add headers as a JSON object, for example {"Content-Type": "application/json"}, and type a body if the method allows one.
  4. Press Build code, then Copy code, and run it yourself in a terminal or a script.

Worked examples

A simple GET as cURL

You enter
Method
GET
Url
https://api.example.test/items
Output
cURL
You get
Code
curl --request GET 'https://api.example.test/items'

With no headers or body the command has only the method and the quoted address.

Run through the tool’s own code.

A JSON POST as cURL

You enter
Method
POST
Url
https://api.example.test/items
Headers
{"Content-Type":"application/json"}
Body
{"name":"Pen","qty":2}
Output
cURL
You get
Code
curl --request POST --header 'Content-Type: application/json' --data-raw '{"name":"Pen","qty":2}' 'https://api.example.test/items'

Each header becomes a --header option and the body goes into --data-raw. Everything is wrapped in single quotes so a shell reads it as one piece.

Run through the tool’s own code.

The same POST as Fetch

You enter
Method
POST
Url
https://api.example.test/items
Headers
{"Content-Type":"application/json"}
Body
{"name":"Pen","qty":2}
Output
JavaScript Fetch
You get
Code
fetch("https://api.example.test/items", { "method": "POST", "headers": { "Content-Type": "application/json" }, "body": "{\"name\":\"Pen\",\"qty\":2}" });

The options object holds the method, the headers and the body as a string. The tool does not add a Content-Type header for you, so type it in the headers box when you need one.

Run through the tool’s own code.

A GET with a body

You enter
Method
GET
Url
https://api.example.test/items
Body
{"a":1}
You get
Message
Enter the requested values and try again.

GET and HEAD requests cannot carry a body here, so the tool shows an error instead of code. Other problems that give the same message are a URL without http or https, a URL with a user name and password in it, and headers that are not a JSON object.

Run through the tool’s own code.

When it helps

  • Turn an API example from documentation into a cURL command you can run in a terminal.
  • Get a Fetch snippet to paste into a small script and then edit.
  • Check how a method, headers and body fit together before you write code by hand.
  • Share a request with a colleague as text, using a placeholder instead of a real token.

Limits to keep in mind

  • The tool sends nothing. It cannot test an endpoint, show a response, or tell you whether the request would work.
  • The URL must start with http or https and must not hold a user name or password. Up to 4,096 characters are allowed.
  • At most 40 headers are allowed, header names must be valid, a value is limited to 2,048 characters and must not contain line breaks. The body is limited to 100,000 characters.
  • Requests run from a browser can still be blocked by CORS, and authentication or server rules may reject them. Check the API's own documentation.

Tips

  • General security advice: do not paste real API keys, tokens or passwords into any online page. Use a placeholder such as YOUR_TOKEN_HERE and put the real value in only when you run the code.
  • General security advice: if a real token was pasted or shared by mistake, revoke it and make a new one, since it may have been copied or logged.
  • Use example or test domains while you learn, and read the API's documentation for the exact headers it needs.

Sources

Common questions

About Create API Request Code — cURL & Fetch.

Does this tool send my request?

No. The page says it builds code only and sends no network request. Press Copy code and run the result yourself in a terminal, a script or the browser console. Nothing on the page contacts the address you typed.

Should I put my real API key or token in the headers box?

General security advice: avoid it. Use a placeholder like Bearer YOUR_TOKEN_HERE in the tool and add the real value only where you run the code. A real token in copied text can end up in chat logs, notes or shell history.

What is the difference between the cURL and Fetch output?

cURL is a command for a terminal. Fetch is JavaScript code for a browser or a recent Node.js version. Both describe the same request. Pick the one that matches where you plan to run it.

Why does it say I cannot use a body with GET?

This tool does not allow a body on GET or HEAD requests and shows an error if you add one. Use POST, PUT, PATCH or DELETE if you need a body, or put the data in the URL query.

Does it add a Content-Type header for me?

No. If you need Content-Type: application/json, type it into the headers box as JSON. Without it the server may not read your body as you expect.

Why was my URL changed in the output?

The address is cleaned by the browser URL parser. For example a space in a query becomes %20, and a bare domain with no http or https is refused. Check that the output address matches what you meant.

Is what I type uploaded?

The page says the code is built locally and that your input is not uploaded. Even so, avoid pasting secrets, especially on a shared or public computer, as the page itself advises.

How do I use API request builder?

Describe a request and copy code for your terminal or JavaScript project; this page does not send it.

Is my data uploaded to a server?

No. This tool runs locally in your browser. Your input is not uploaded.