cURL to MATLAB Converter
Convert curl commands to MATLAB code using webread / webwrite. Paste a command and the MATLAB snippet appears instantly — everything runs in your browser.
- Instant ConversionCode updates as you type
- Multiple Languages40 languages, 61 libraries
- 100% Client SideYour data stays private
How to use this tool
Steps for using the cURL to Code.
- Copy a curl command — from API documentation, or from your browser's DevTools (Network tab → right-click a request → Copy as cURL (bash)).
- Paste it into Enter cURL command. The MATLAB webread / webwrite code appears instantly.
- Set up: Nothing to install — they're part of MATLAB.
- Run it: Run the script in MATLAB. Replace placeholders such as
YOUR_TOKENfirst, and check any notes under the editors for curl options that have no webread / webwrite equivalent.
Example
GET with headers → MATLAB webread / webwrite
curl 'https://api.example.com/v1/users?page=2' \
-H 'Accept: application/json' \
-H 'Authorization: Bearer YOUR_TOKEN'url = 'https://api.example.com/v1/users?page=2';
options = weboptions( ...
'HeaderFields', { ...
'Accept', 'application/json'; ...
'Authorization', 'Bearer YOUR_TOKEN' ...
}, ...
'ContentType', 'json');
% webread/webwrite return only the body and throw an error for non-2xx responses.
response = webread(url, options);
disp(response);Common use cases
- Loading data from web APIs into MATLAB
- Posting results to a service
Converting curl to MATLAB webread / webwrite
webread and webwrite are MATLAB's built-in functions for HTTP, configured with weboptions.
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 webread / webwrite code. Options that have no webread / webwrite equivalent are listed under the editors rather than silently dropped.
Limitations
- webread/webwrite return only the body and throw an error for non-2xx responses; use matlab.net.http for full control.
- 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
How do I get the status code in MATLAB?
webread/webwrite don't return it. Use the matlab.net.http.RequestMessage API if you need status codes and response headers.
Does MATLAB parse JSON responses?
Yes — with ContentType 'json' (or auto), JSON is returned as MATLAB structs.
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.