How cURL → fetch works
Paste a curl command and get equivalent JavaScript fetch() code. Toggle between a browser snippet and a Node 18+ version. Headers, methods, JSON bodies, and basic auth are all carried across.
A shell-aware tokenizer parses the command (respecting quotes and line continuations), then the flags are mapped to a fetch() options object. JSON bodies are pretty-printed. Runs entirely in your browser.
Questions
- Which curl flags are understood?
- Method (-X/--request), headers (-H/--header), data (-d/--data/--data-raw/--data-binary), basic auth (-u/--user), and the URL. Common no-op flags like --compressed and -s are ignored.
- Does it pretty-print JSON bodies?
- Yes. If the -d payload is valid JSON, the output wraps it in JSON.stringify with indentation. Non-JSON bodies are passed through as a string.
- What is the difference between Browser and Node?
- The Node variant adds a comment noting it targets Node 18+ where fetch is global. The fetch call itself is identical; both assume top-level await.
- Is my command sent anywhere?
- No. Parsing and code generation happen entirely in your browser.
More Text & Data tools
- .env InspectorInspect, mask, and convert env files
- JSONPath ExplorerPull a value out of JSON by path
- Markdown PreviewerLive GitHub-flavored markdown
- JSON FormatterValidate and pretty-print
- Base64Encode and decode
- Diff CheckerCompare two text blocks
- Word CountCount, readability, stats
- TimestampUnix, ISO 8601, relative time
- Hash GeneratorSHA-1, SHA-256, SHA-512
- URL EncoderEncode, decode, parse URLs
- Text CaseUPPER, lower, Title, camelCase, more
- Character EntitiesHTML entities, Unicode, ASCII lookup
- JSON to TypeScriptGenerate TypeScript interfaces from JSON
- JWT DecoderInspect JSON Web Tokens
- Page WeightWeigh a page: bytes, grade, Core Web Vitals, HAR diff
- SQL Viewer & CopyOpen a .sql file, read it, copy it
- SQL Formatter & MinifyBeautify or compact SQL
- SQL SplitterSplit a migration into statements
- SQL Pre-flight CheckCatch RLS gaps & risky SQL
- Base ConverterBinary, octal, decimal, hex, bitwise
- Unicode InspectorCode points, bytes, invisible characters