HTTP Request Code Generator
About this tool
About HTTP Request Code Generator
Describe an API call once and get it in the tool you are about to use. Start from one of 25 request templates for common API shapes: a GET with a bearer token, paginated and cursor lists, JSON create, PUT, PATCH and DELETE, multipart upload, OAuth 2.0 client credentials, GraphQL, a signed webhook, server-sent events, an idempotent payment and conditional requests with ETags. Your own API host and token are kept when you switch. Or build it yourself: method, URL, query rows, headers, Basic or Bearer auth and a JSON, form, multipart or raw body. The code updates as you type, in eight flavours: cURL, browser fetch, Node.js fetch, Axios, HTTPie, Python requests, Go net/http and PHP cURL. Query values are percent-encoded, JSON is validated, the Content-Type header is added for you, and multipart requests let the client set the boundary. It is a code generator only: nothing is sent from this page, so you can safely fill in real tokens. Optionally, describe the call in words and AI fills the form using your own key.
Built and maintained by Abhi JainUpdated
How to Generate HTTP Request Code
- 1
Start from a template
Pick an API shape in Request templates, or choose the Method, type the URL and add Query parameters and Headers as rows.
- 2
Add auth and body
Pick an Authorization type and a Body type (JSON, Form URL-encoded, Multipart or Raw text) and fill it in.
- 3
Choose the output
Click cURL, fetch, Axios, HTTPie, Python, Node.js, Go or PHP above the code.
- 4
Copy or download
Copy the snippet or download it as a file and run it in your terminal or app.
HTTP Request Code Generator: questions and answers
Does this tool send my request?
No. It only writes code. Nothing is sent from the page, so there are no CORS errors and your tokens stay on your device. Run the generated command or code yourself.
Should I set Content-Type for multipart/form-data myself?
No. The boundary in the header must match the one in the body, so let the client generate it. The generated code never hard-codes a multipart Content-Type, and removes one if you added it.
What is the difference between JSON and form URL-encoded bodies?
A JSON body is sent as application/json text such as {"name":"Ann"}. A URL-encoded form is sent as application/x-www-form-urlencoded key=value pairs joined with &, like an HTML form. APIs usually document which one they accept.
What request templates are included?
25 templates in six groups: reading (bearer GET, page-number and cursor pagination, search with filters), writing (JSON create, PUT, PATCH, DELETE, bulk create, JSON:API), auth (API key header, Basic, OAuth 2.0 client credentials and refresh token, form login), files (multipart upload, resumable Range download), protocols (GraphQL, signed webhook, server-sent events, XML) and reliability (Idempotency-Key, If-None-Match, If-Match, HEAD health check). They use example.com hosts and YOUR_API_TOKEN style placeholders; a bearer token goes in the Authorization: Bearer header.
Can AI help me build the request?
Yes, optionally. Click AI on the Request panel, describe the call, and the method, URL, query, headers, auth type and body are filled in for you to review. Only your description is sent, never the form or its tokens; credentials come back as placeholders. It uses the AI provider and key you connect in AI settings (Claude, OpenAI, Gemini, DeepSeek, OpenRouter or a compatible endpoint), and the request goes straight from your browser to that provider; KissThePDF has no server in between.
Can a GET request have a body?
The HTTP spec gives a GET body no defined meaning, browsers' fetch refuses one, and many servers ignore it. Put GET data in query parameters instead; the tool warns you if you add a body to GET or HEAD.
Ready-made HTTP Request Code Generator presets
Related Tools
- cURL ConverterTurn a cURL command into fetch, Axios, Python, Go, PHP, Node or HTTPie code.
- Query String BuilderTurn key/value rows into an encoded query string and back again.
- HTTP Headers ReferenceSearchable reference of HTTP request and response headers with examples.
- JSON FormatterBeautify, minify and validate JSON with exact error locations, without changing a single value.