cURL to Dart

Paste a curl command and get Dart code that makes the same request with package:http.

cURL to Dart parses your command in the browser. Credentials in the command never leave your device.

Convert to Swift instead

About cURL to Dart

Backend documentation gives you a curl command; a Flutter app needs Dart. This converter bridges the two, parsing the curl flags the way curl itself does and emitting code that uses package:http — the package almost every Dart and Flutter project already depends on. Headers are collected into a typed map, a JSON body becomes a Dart map encoded with jsonEncode rather than a pasted string, and basic auth is rebuilt with base64Encode from the decoded credentials. Verbs that the shorthand helpers do not cover fall back to an http.Request, so an unusual method still produces working code instead of a silent gap.

Features

How to use the cURL to Dart

  1. Paste the curl command from your API documentation
  2. Read the generated Dart on the right
  3. Check any warnings about flags that could not be carried over
  4. Copy the code, or download it as a .dart file

Example

Input

curl -X PUT https://api.example.com/users/1 -H 'Authorization: Bearer TOKEN' -d '{"role":"admin"}'

Output

final response = await http.put(url, headers: headers, body: body);

The verb comes from -X, and the JSON body is built as a Dart map before encoding.

Common errors & troubleshooting

Frequently asked questions

Does the generated code work in a Flutter app?
Yes. package:http works the same in Flutter and in plain Dart, so the request code can be pasted into a service class as-is. Only the printing at the end is worth replacing with whatever your app does with the response.
Should I use package:http or Dio?
package:http is the smaller, official option and covers most requests. Dio adds interceptors, cancellation and multipart conveniences, and its API is close enough that translating this output is straightforward.
How is a JSON body converted?
It is parsed and written out as a Dart map literal, then encoded with jsonEncode. That keeps nested objects and arrays readable, and lets you replace values with variables directly.
What if the method has no http.get style helper?
The generated code builds an http.Request with the verb as a string and sends it through send(), which handles PURGE, LINK or anything else an API might use.
Is the curl command uploaded to convert it?
No. Parsing and code generation happen in your browser, so bearer tokens and API keys inside the command stay on your device.

Related tools

All ArrayKit tools