Code converters

cURL to Dart and Flutter Converter

Paste a cURL command and get formatted Dart for the http package or Dio, ready for a Flutter app or a command-line script.

  • Free foreverNo trial, no paywall, no usage limits.
  • No sign-upOpen the page and start. We never ask for an email to use a tool.
  • PrivateEverything runs in your browser. Your input is never uploaded or stored on our servers.
  • Works offlineOnce the page has loaded, the tool keeps working without a connection.
InputAuto-detects Bash (Copy as cURL (bash), API docs), Windows cmd (Copy as cURL (cmd), with ^ escapes) and PowerShell (backtick line breaks). Pick one if the guess is wrong.
package:http, maintained by the Dart team. Small, composable, works on every platform.Dio: interceptors, FormData, cancel tokens and timeouts built in. Popular in larger Flutter apps.
http returns every response, even a 500: this adds a status check. With Dio (which throws on errors) it adds a DioException handler.
curl follows redirects only with -L. On: without -L the code stops at a 3xx response, exactly like curl. Off: keep the library's default.
Leaves out headers a browser adds by itself (sec-ch-ua, sec-fetch-*, priority…). They are noise when you replay a DevTools request from code.

cURL command

Paste a command from DevTools (Copy as cURL), API docs or your terminal. You can also drop a .sh or .txt file here.
Clear

Dart · http

Runnable Dart that sends the same request. Lines marked in amber contain credentials.
Wrap long linesCopyDownload request.dart
Your Dart code appears here as you type.
Nothing leaves your browser.
Paste a command or load an example. It converts as you type, and nothing leaves your browser.

Parsed request

What curl would send, decoded: method, URL, query, headers, cookies and body.

Paste a command to see its method, URL, query parameters, headers, cookies and body, decoded.

Need this built into your own API or pipeline? Talk to our team

Quick answer

To convert cURL to Dart, build the request with the http package: Uri.parse() the URL, pass the -H values as a headers map, encode a JSON body with jsonEncode, and use http.MultipartRequest for -F uploads. Paste a cURL command into Playxoft's free cURL to Dart converter to get runnable code for http or Dio, laid out the way dart format would, that drops straight into a Flutter app.

  • http or Dio
  • dart format layout
  • JSON, forms and multipart
  • Timeouts, -k and proxies
  • Credential warnings
  • Flutter ready

How to use the cURL to Dart Converter

  1. 1Paste a command into cURL command, or choose one from Load example.
  2. 2Choose http or Dio.
  3. 3Keep Check status on so error responses throw instead of passing silently.
  4. 4Check Parsed request and the notes, especially for -k and proxies, which work on mobile, desktop and servers but not on the web.
  5. 5Add the package with flutter pub add http (or dio), then copy the code or download request.dart.

cURL flags cheat sheet: what does each option become in Dart?

cURLpackage:httpDio
The URLUri.parse('…')The URL string
-X POSThttp.post(…)dio.post(…)
-H "Name: value"headers: {'Name': 'value'}Options(headers: {…})
A JSON bodybody: jsonEncode({…})data: {…}
-d "a=1&b=2"body: {'a': '1', 'b': '2'}data: {…} with a form content type
-F file=@a.pnghttp.MultipartRequest with MultipartFile.fromPathFormData.fromMap with MultipartFile.fromFile
-u user:passAn Authorization: Basic headerSame
-m 30.timeout(const Duration(seconds: 30))receiveTimeout (per-chunk idle time; wrap the call in .timeout() for a hard cap)
--connect-timeout 5HttpClient.connectionTimeoutconnectTimeout
-kbadCertificateCallback on an HttpClientThe same, through IOHttpClientAdapter
-x host:8080findProxy on an HttpClientThe same, through IOHttpClientAdapter

The http package sends a Map<String, String> body as an HTML form and sets that content type itself. A String body is sent as is, so JSON needs both jsonEncode and a JSON Content-Type header. Dio encodes maps as JSON unless you ask for a form.

http vs Dio: which should you use in Flutter?

httpDio
MaintainerThe Dart teamThe community (cfug)
Error responsesReturned like any other responseThrow a DioException
TimeoutsFuture.timeout on each callConnect, send and receive timeouts
InterceptorsWrap the client yourselfBuilt in
UploadsMultipartRequestFormData with progress callbacks
CancellingAbortableRequest with an abortTrigger (http 1.5+)CancelToken

Start with http: it is small, maintained by the Dart team and enough for most apps. Reach for Dio when many calls need the same interceptors (token refresh, logging, retries), or when you want upload progress built in.

How do I use the converted code in a Flutter app?

The generated code runs as is with dart run. To use it in Flutter:

  1. Add the package: flutter pub add http (or dio). Multipart uploads with a content type also need flutter pub add http_parser.
  2. Move the body of main() into an async method, such as Future<User> fetchUser(), and call it from a FutureBuilder or your state management.
  3. On Android, release builds need the internet permission in AndroidManifest.xml: <uses-permission android:name="android.permission.INTERNET" />. Debug builds include it automatically.
  4. On macOS, enable the com.apple.security.network.client entitlement.
  5. Prefer https URLs: Android 9 and later block plain http traffic by default.

Code that reads a File or creates its own HttpClient (for -k, proxies or connect timeouts) depends on dart:io, so it doesn't run on Flutter web.

How do I handle errors and retries with Dio?

Dio throws a DioException for timeouts, connection failures and, by default, any status outside 2xx. Its type tells you which one happened, so you can decide what is worth retrying:

try {
  final response = await dio.get('https://api.example.com/v1/orders');
  print(response.data);
} on DioException catch (e) {
  if (e.type == DioExceptionType.badResponse) {
    print('HTTP ${e.response?.statusCode}: ${e.response?.data}');
  } else if (e.type == DioExceptionType.connectionTimeout ||
      e.type == DioExceptionType.receiveTimeout) {
    print('Timed out; safe to retry a GET');
  } else {
    rethrow;
  }
}

Dio doesn't retry on its own. Add a retry interceptor (the dio_smart_retry package is one) or loop with a short delay, and retry only idempotent requests such as GET, PUT and DELETE unless the API supports idempotency keys. Create one Dio instance with your base URL, headers and interceptors and reuse it across the app, rather than calling Dio() per request.

Copying requests from a browser? See how to copy as cURL in Chrome or Firefox DevTools. Browser copies carry headers a mobile app never sends, such as sec-ch-ua and origin: turn on Drop browser headers for the sec-* group and delete origin and referer unless the API checks them.

Can I ship API keys copied from a cURL command in a Flutter app?

No. Anything compiled into an app can be pulled out of the APK or IPA, so a key in your Dart code is effectively public. Keep secrets on a server you control and have the app call it, or use short-lived tokens issued to each user after sign-in.

The converter itself is private: it runs in your browser and never uploads your command. While testing, read values from the environment: $API_TOKEN in the command becomes Platform.environment['API_TOKEN']! in the generated Dart. That suits scripts; Flutter apps usually pass build-time values with --dart-define, which are not secret either.

The Contains credentials badge flags anything still hard-coded, and a badCertificateCallback that returns true must never reach a release build.

Frequently asked questions

Use the http package: await http.post(Uri.parse(url), headers: {'Content-Type': 'application/json'}, body: jsonEncode(data)). jsonEncode comes from dart:convert. Without the Content-Type header the body goes out as text/plain and many APIs reject it.
Create an http.MultipartRequest('POST', uri), add text fields to request.fields and files with await http.MultipartFile.fromPath('file', path), then call request.send() and read the reply with http.Response.fromStream. With Dio, pass FormData.fromMap with MultipartFile.fromFile as data.
Call .timeout(const Duration(seconds: 30)) on the request future; it throws a TimeoutException if the response takes longer. For a connect timeout, create a dart:io HttpClient, set connectionTimeout and wrap it in an IOClient. Dio has connectTimeout and receiveTimeout options.
Create an HttpClient, set badCertificateCallback to (cert, host, port) => true, and pass it to an IOClient (or to Dio through IOHttpClientAdapter). It works on mobile, desktop and servers, not on the web. Use it only against test servers, never in a release build.
Use http for most apps: it is small and maintained by the Dart team. Choose Dio when you need interceptors for token refresh or logging, upload progress, or request cancellation. The converter generates either one from the same cURL command.
No. The converter parses the command and writes the Dart code entirely in your browser. Nothing is uploaded or stored, and reloading the page clears it.

Last updated by the Playxoft engineering team.

From the engineers who built this tool

Fighting messy data every day?

When payloads, schemas and integrations keep breaking, the fix is usually upstream. We design typed APIs and backends that stay clean as you grow. Tell us what you are building and we will suggest the simplest architecture that fits.

More free tools

See all tools

SQL Formatter

Beautify or minify SQL in 12 dialects, with keyword case, indent and line:column errors.

Open tool

cURL to Python Converter

New

Convert cURL commands into Python requests or httpx code with params, json, files and auth.

Open tool

cURL to Fetch Converter

New

Turn any cURL command into JavaScript fetch() code with headers, JSON, forms and auth.

Open tool

cURL to Axios Converter

New

Convert cURL commands into an Axios request config with params, data, auth and timeouts.

Open tool

SQL to Prisma Converter

Turn SQL DDL into a schema.prisma with native types, relations and enums.

Open tool

SQL to Drizzle Converter

Turn SQL DDL into a typed Drizzle schema.ts with indexes, enums and relations().

Open tool