{"id":13396161,"url":"https://github.com/curlconverter/curlconverter","last_synced_at":"2025-12-17T13:06:34.980Z","repository":{"id":25049107,"uuid":"28468993","full_name":"curlconverter/curlconverter","owner":"curlconverter","description":"Transpile curl commands into Python, JavaScript and 27 other languages","archived":false,"fork":false,"pushed_at":"2025-02-07T11:20:51.000Z","size":2787,"stargazers_count":7765,"open_issues_count":53,"forks_count":970,"subscribers_count":73,"default_branch":"master","last_synced_at":"2025-05-05T17:21:34.592Z","etag":null,"topics":["curl","tree-sitter"],"latest_commit_sha":null,"homepage":"https://curlconverter.com","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/curlconverter.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2014-12-25T03:07:06.000Z","updated_at":"2025-05-04T16:34:02.000Z","dependencies_parsed_at":"2023-01-16T22:15:57.176Z","dependency_job_id":"88184836-a7f2-4824-b485-55812ed081d3","html_url":"https://github.com/curlconverter/curlconverter","commit_stats":{"total_commits":609,"total_committers":48,"mean_commits":12.6875,"dds":0.5829228243021347,"last_synced_commit":"aa8c66cd0982291eb0c37bcd7131180d70a9ee88"},"previous_names":["nickcarneiro/curlconverter"],"tags_count":26,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/curlconverter%2Fcurlconverter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/curlconverter%2Fcurlconverter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/curlconverter%2Fcurlconverter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/curlconverter%2Fcurlconverter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/curlconverter","download_url":"https://codeload.github.com/curlconverter/curlconverter/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253834392,"owners_count":21971604,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["curl","tree-sitter"],"created_at":"2024-07-30T18:00:41.525Z","updated_at":"2025-12-17T13:06:34.973Z","avatar_url":"https://github.com/curlconverter.png","language":"TypeScript","funding_links":[],"categories":["TypeScript","HarmonyOS","Dev-Tools","Utilities","others","Command Line","语言资源库","👨‍💻 Programming","Repositories"],"sub_categories":["Windows Manager","Self-hosted","CLI Tools","typescript","online tools"],"readme":"# [curlconverter](https://curlconverter.com)\n\nTranspile [`curl`](https://en.wikipedia.org/wiki/CURL) commands into C, C#, ColdFusion, Clojure, Dart, Elixir, Go, HTTPie, Java, JavaScript, Julia, Kotlin, Lua, MATLAB, Objective-C, OCaml, Perl, PHP, PowerShell, Python, R, Ruby, Rust, Swift, Wget, Ansible, HAR, HTTP or JSON.\n\nTry it on [curlconverter.com](https://curlconverter.com) or as a drop-in `curl` replacement:\n\n```shell\n$ curlconverter --data \"hello=world\" example.com\nimport requests\n\ndata = {\n    'hello': 'world',\n}\n\nresponse = requests.post('http://example.com', data=data)\n```\n\nFeatures:\n\n- Implements a lot of curl's argument parsing logic\n  - Knows about all 255 curl arguments but most are ignored\n  - Supports shortening `-O -v -X POST` to `-OvXPOST`\n  - `--data @filename` generates code that reads that file and `@-` reads stdin\n- Understands Bash syntax\n  - [ANSI-C quoted](https://www.gnu.org/software/bash/manual/bash.html#ANSI_002dC-Quoting) strings\n  - stdin redirects and [heredocs](https://www.gnu.org/software/bash/manual/bash.html#Here-Documents)\n  - Generated code reads environment variables and runs subcommands\n  - Ignores comments\n  - Reports syntax errors\n- Converts JSON data to native objects\n- Warns about issues with the conversion\n\nLimitations:\n\n- Only HTTP is supported\n- Code generators for other languages are less thorough than the Python generator\n- curl doesn't follow redirects or decompress gzip-compressed responses by default, but the generated code will do whatever the default is for that runtime, to keep it shorter. For example Python's Requests library [follows redirects by default](https://requests.readthedocs.io/en/latest/user/quickstart/#redirection-and-history), so unless you explicitly set the redirect policy with `-L`/`--location`/`--no-location`, the generated code will not handle redirects the same way as the curl command\n- Shell variables can arbitrarily change how the command would be parsed at runtime. The command `curl $VAR` can do anything, depending on what's in `$VAR`. curlconverter assumes that environment variables don't contain characters that would affect parsing\n- Only simple subcommands such as `curl $(echo example.com)` work, more complicated subcommands (such as nested commands or subcommands that redirect the output) won't generate valid code\n- The Bash parser doesn't support all Bash syntax\n- and much more\n\n## Install\n\nInstall the command line tool with\n\n```sh\nnpm install --global curlconverter\n```\n\nInstall the JavaScript library for use in your own projects with\n\n```sh\nnpm install curlconverter\n```\n\n## Usage\n\n### Usage from the command line\n\n`curlconverter` acts as a drop-in replacement for curl. Take any curl command, change \"`curl`\" to \"`curlconverter`\" and it will print code instead of making the request\n\n```shell\n$ curlconverter example.com\nimport requests\n\nresponse = requests.get('http://example.com')\n```\n\nTo read the curl command from stdin, pass `-`\n\n```shell\n$ echo 'curl example.com' | curlconverter -\nimport requests\n\nresponse = requests.get('http://example.com')\n```\n\nChoose the output language by passing `--language \u003clanguage\u003e`. The options are\n\n- `ansible`\n- `c`\n- `cfml`\n- `clojure`\n- `csharp`\n- `dart`\n- `elixir`\n- `go`\n- `har`\n- `http`\n- `httpie`\n- `java`, `java-httpurlconnection`, `java-jsoup`, `java-okhttp`\n- `javascript`, `javascript-jquery`, `javascript-xhr`\n- `json`\n- `julia`\n- `kotlin`\n- `lua`\n- `matlab`\n- `node`, `node-http`, `node-axios`, `node-got`, `node-ky`, `node-request`, `node-superagent`\n- `objc`\n- `ocaml`\n- `perl`\n- `php`, `php-guzzle`, `php-requests`\n- `powershell`, `powershell-webrequest`\n- `python` (the default), `python-http`\n- `r`, `r-httr2`\n- `ruby`, `ruby-httparty`\n- `rust`\n- `swift`\n- `wget`\n\n`--verbose` enables printing of conversion warnings and error tracebacks.\n\n### Usage as a library\n\nThe JavaScript API is a bunch of functions that can take either a string of Bash code or an array of already-parsed arguments (like [`process.argv`](https://nodejs.org/docs/latest/api/process.html#processargv)) and return a string with the resulting program:\n\n```js\nimport * as curlconverter from 'curlconverter';\n\ncurlconverter.toPython('curl example.com');\ncurlconverter.toPython(['curl', 'example.com']);\n// \"import requests\\n\\nresponse = requests.get('http://example.com')\\n\"\n```\n\n**Note**: add `\"type\": \"module\",` to your package.json for the `import` statement above to work. curlconverter must be imported as an ES module with `import` this way and not with `require()` because it uses [top-level `await`](https://v8.dev/features/top-level-await).\n\nThere's a corresponding set of functions that also return an array of warnings if there are any issues with the conversion:\n\n```js\ncurlconverter.toPythonWarn('curl ftp://example.com');\ncurlconverter.toPythonWarn(['curl', 'ftp://example.com']);\n// [\n//   \"import requests\\n\\nresponse = requests.get('ftp://example.com')\\n\",\n//   [ [ 'bad-scheme', 'Protocol \"ftp\" not supported' ] ]\n// ]\n```\n\nIf you want to host curlconverter yourself and use it in the browser, it needs two [WASM](https://developer.mozilla.org/en-US/docs/WebAssembly) files to work, `tree-sitter.wasm` and `tree-sitter-bash.wasm`, which it will request from the root directory of your web server. If you are hosting a static website and using Webpack, you need to copy these files from the node_modules/ directory to your server's root directory in order to serve them. You can look at the [webpack.config.js](https://github.com/curlconverter/curlconverter.github.io/blob/2e1722891be22b1bb5c47976fb7873f6eb86b94d/webpack.config.js#L130-L131) for [curlconverter.com](https://curlconverter.com/) to see how this is done. You will also need to set `{module: {experiments: {topLevelAwait: true}}}` in your webpack.config.js.\n\n### Usage in VS Code\n\nThere's a VS Code extension that adds a \"Paste cURL as \\\u003clanguage\\\u003e\" option to the right-click menu: [https://marketplace.visualstudio.com/items?itemName=curlconverter.curlconverter](https://marketplace.visualstudio.com/items?itemName=curlconverter.curlconverter). It doesn't support the same languages, curl arguments or Bash syntax as the current version because it has to [use an old version of curlconverter](https://github.com/curlconverter/curlconverter-vscode/issues/1).\n\n## Contributing\n\nSee [CONTRIBUTING.md](./CONTRIBUTING.md)\n\n## License\n\nMIT © [Nick Carneiro](http://trillworks.com)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcurlconverter%2Fcurlconverter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcurlconverter%2Fcurlconverter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcurlconverter%2Fcurlconverter/lists"}