Skip to content
koducathome

cURL to Dart Converter

Convert curl commands to Dart code using http. Paste a command and the Dart snippet appears instantly — everything runs in your browser.

How to use this tool

Steps for using the cURL to Code.

  1. Copy a curl command — from API documentation, or from your browser's DevTools (Network tab → right-click a request → Copy as cURL (bash)).
  2. Paste it into Enter cURL command. The Dart http code appears instantly.
  3. Set up: Add the package with dart pub add http (or flutter pub add http).
  4. Run it: Run the file with dart run request.dart, or call the code from your Flutter app. Replace placeholders such as YOUR_TOKEN first, and check any notes under the editors for curl options that have no http equivalent.

Example

GET with headers → Dart http

curl command
curl 'https://api.example.com/v1/users?page=2' \
  -H 'Accept: application/json' \
  -H 'Authorization: Bearer YOUR_TOKEN'
Dart http
import 'package:http/http.dart' as http;

Future<void> main() async {
  final request = http.Request('GET', Uri.parse('https://api.example.com/v1/users?page=2'));
  request.headers.addAll({
    'Accept': 'application/json',
    'Authorization': 'Bearer YOUR_TOKEN',
  });

  final client = http.Client();
  try {
    final response = await http.Response.fromStream(await client.send(request));
    print(response.statusCode);
    print(response.body);
  } finally {
    client.close();
  }
}

Common use cases

  • Flutter apps talking to a backend
  • Dart command-line tools
  • Testing APIs from Dart

Converting curl to Dart http

The http package is the standard way to make HTTP requests in Dart and Flutter.

The converter reads the curl command the way curl does — the method (-X), headers (-H), request bodies (-d, --data-raw, --json, -F), query strings, basic auth (-u) and cookies — and writes the equivalent http code. Options that have no http equivalent are listed under the editors rather than silently dropped.

Limitations

  • The code is a starting point: add timeouts, retries and error handling for production use.
  • Secrets in the curl command are copied into the code — move them to environment variables before committing.

Frequently asked questions

Does this work in Flutter?

Yes — package:http works in Flutter on mobile, desktop and web (on the web, CORS rules apply).

How do I parse a JSON response?

Use jsonDecode(response.body) from dart:convert.

Is my curl command sent to a server?

No. The conversion runs entirely in your browser, so tokens and passwords in the command never leave your device. Still, replace real secrets before sharing the generated code.