Convert cURL Commands to MATLAB Code
Paste a cURL command into the converter and it returns MATLAB HTTP code.
The output shows two approaches: a short webread call and a matlab.net.http RequestMessage flow. Use this page to decide which one fits your request and to understand what each line does.
What the converter does
The converter takes a cURL command as input and produces MATLAB code that performs the same HTTP request. The output is shown in a code block with a copy-to-clipboard control so you can paste it into your MATLAB script or live script. The input area is a textarea labelled for the cURL command you want to convert; the output area is a code block labelled as MATLAB code.
Choosing between webread and matlab.net.http
The converter returns two MATLAB approaches. The first uses webread, which is the shortest path for a simple GET request. The second uses matlab.net.http with a URI and a RequestMessage, which gives you control over headers, methods and body content. Use webread when the request is a plain GET with no custom headers. Use the RequestMessage path when you need to set headers, send a POST body, or inspect the response object in detail.
Worked example: converting a simple request
The converter's default input is curl example.com. The output shows both MATLAB paths for that request. The webread path sets uri to 'http://example.com' and calls webread(uri). The RequestMessage path imports matlab.net.* and matlab.net.http.*, builds a URI from the same address, and sends a RequestMessage to uri.EncodedURI. For a request with headers or a body, the converter would populate those fields in the RequestMessage path; the webread path stays short because it does not carry custom headers.
Field and control map
The converter has two main controls. The input textarea holds the cURL command; its default value is curl example.com. The output code block shows the generated MATLAB code. A copy-to-clipboard button sits with the output so you can move the code into your editor. The page also links to guides for extracting cURL commands from Chrome, Safari and Firefox, and to converters for other languages.
Common failure distinctions
When a converted request fails, separate transport problems from parsing problems. A transport failure means MATLAB could not reach the host or the request was rejected; check the URI, headers and method. A parsing failure means the response arrived but MATLAB could not interpret it; check the content type and how you read the response body. The webread path returns parsed data directly, while the RequestMessage path returns a response object you must inspect. Knowing which path you used narrows the cause quickly.
Related converters
The same converter pattern is available for CFML, Dart, Elixir, Go, Java, JavaScript Fetch, JSON, NodeJS with Axios, NodeJS with fetch, NodeJS with Request, PHP, Python, R and Rust. Use the matching converter when your target language is not MATLAB.
Frequently asked questions
Does the converter send the request for me?
No. It produces MATLAB code that you run in your own MATLAB environment. The converter itself does not execute the request.
Which MATLAB path should I use for a POST request?
Use the matlab.net.http RequestMessage path. It lets you set the method and body, while webread is suited to simple GET requests.
Can I copy the generated code directly?
Yes. The output block includes a copy-to-clipboard control so you can paste the code into your MATLAB editor.