cURL to TypeScript

Turn cURL into typed fetch in TypeScript.

{{ curlToTypescript.message }}

Overview

Daniel Stenberg launched cURL in 1998, starting as a personal project called `httpget` to download currency exchange rates. The name evolved — first `urlget`, then `curl` — short for Client URL, and it stuck. Today curl is installed on virtually every Linux server, Mac, Android device, and modern Windows system, with estimates suggesting over 20 billion active installations. That makes it arguably the most ubiquitous command-line software in the world. The flag syntax we use today — `-H` for headers, `-d` for the request body, `-X` for the HTTP method, `-u` for basic auth — was established in the early versions and has survived more than 25 years without major changes. When an interface works that well, it just stays.

TypeScript was announced by Anders Hejlsberg at Microsoft in October 2012, as a response to a real problem: developing large-scale JavaScript applications was painful without static typing. Hejlsberg was no newcomer to that territory — he had created Turbo Pascal at age 20, then Delphi, then C#, and then TypeScript. The `fetch` API, which replaced `XMLHttpRequest` as the modern way to make HTTP requests in browsers and Node.js, returns Promises and accepts an object with `method`, `headers`, and `body`. In TypeScript, you can type the expected response: `const data = await response.json() as MyType`, which makes the code autocomplete-friendly and safer during development — the compiler warns you when you try to access a property that does not exist in the declared type.

In the daily work of consuming APIs, documentation almost always comes with a curl example — it is the universal format every provider uses, from Stripe to GitHub. But when you are developing in TypeScript, you need to manually translate that curl into compatible code. This involves converting headers from `-H 'Content-Type: application/json'` into a JavaScript object, the body from `--data` into the request's `body` field, and the method from `-X POST` into `method: 'POST'`. This converter automates that work and generates a snippet ready to paste into any TypeScript, React, Next.js, or Deno project. The output uses native `fetch`, but adapting it to Axios or ky is straightforward if you prefer a library with built-in retry and interceptors.

Technical deep dive

Common questions summarized

  • What is this tool for?: It runs fully in your browser: useful to validate, format, or convert data in everyday development.
  • Are my inputs sent to a server?: Processing happens locally with JavaScript. We do not store what you paste into the text areas.
  • Can I use this for real production data?: Use at your own risk. For secrets (passwords, tokens), prefer controlled environments and your company policies. And always review the generated contents. Never trust blindly things you see on the internet.

Sample payload to try

  • See also the larger "Code Snippets" sample; paste this excerpt to try locally: Example — curl 'https://api.example.com/orders' -H 'Accept: application/json'

Tool guide

  • What cURL is A concise representation of HTTP request setup.

  • What TypeScript is and where it is used TypeScript adds static types to JavaScript and is common in modern frontend and Node projects.

  • What object the tool manipulates cURL command converted to typed TypeScript fetch snippet.

  • What the tool does Generates typed request code with headers and response parsing.

Code Snippets

Code example
curl 'https://api.example.com/orders' -H 'Accept: application/json'

Example

curl 'https://api.example.com/orders' -H 'Accept: application/json'

FAQ

What is this tool for?

It runs fully in your browser: useful to validate, format, or convert data in everyday development.

Are my inputs sent to a server?

Processing happens locally with JavaScript. We do not store what you paste into the text areas.

Can I use this for real production data?

Use at your own risk. For secrets (passwords, tokens), prefer controlled environments and your company policies. And always review the generated contents. Never trust blindly things you see on the internet.