curl2rsc

Convert curl commands to MikroTik RouterOS /tool/fetch scripting (.rsc)

Examples: GET · POST JSON · Basic Auth · Form · Custom Headers
Loading…
How to get a curl command from your browser
  1. Open the Network tab in DevTools
  2. Right-click (or Ctrl-click) a request
  3. Click CopyCopy as cURL
  4. Paste it in the box above
  1. Open the Network tab in Developer Tools
  2. Right-click (or Ctrl-click) a request
  3. Click Copy as cURL
  4. Paste it in the box above
  1. Open the Network Monitor in Developer Tools
  2. Right-click (or Ctrl-click) a request
  3. Click CopyCopy as cURL
  4. Paste it in the box above
Warning: The copied command may contain cookies, tokens, or other credentials. Redact secrets before sharing.
Output styles & RouterOS notes
Output styles
/tool/fetch (simple)
Bare /tool/fetch command — run directly in terminal or script.
:put to terminal
Wraps in :put to print the response body to the terminal.
Save to variable
Stores the response in a global variable $resp for further scripting.
Variable + headers
Like “Save to variable” but also captures response headers.
Output to file
Writes the response body to a file on the RouterOS filesystem.

JSON responses & :deserialize

When the request targets a JSON API, RouterOS can parse the response natively:

:global resp [/tool/fetch url=… as-value output=user]
:global json [:deserialize ($resp->"data") from=json]
:put $json

:deserialize is available in all current RouterOS releases (long-term and newer).


What curl2rsc cannot convert
  • -L / --location/tool/fetch does not follow redirects.
  • --compressed — no automatic decompression support.
  • Local file uploads (-F @file) — /tool/fetch has no native file-upload support. The generated script uses $[/file get … contents] to read a plain-text file that must already exist on the RouterOS device. Binary files and complex payloads require manually constructing the multipart body using [:convert] and /file commands.
  • HTTP methods beyond GET, HEAD, POST, PUT, DELETE, PATCH.

Behind the curtain — parsing uses curlconverter with Tree-sitter WASM, entirely in the browser. The RouterOS generator is extracted from tikoci/postman-code-generators. No server is contacted.
Request details

Parse a curl command to see request details.


Parsed JSON
Awaiting input…