cURL to Ansible Converter
Convert curl commands to Ansible code using uri module. Paste a command and the Ansible 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 Ansible uri module code appears instantly.
- Set up: Ansible includes the
urimodule — no extra collection is needed. - Run it: Put the tasks in a play and run it with
ansible-playbook playbook.yml. Replace placeholders such asYOUR_TOKENfirst, and check any notes under the editors for curl options that have no uri module equivalent.
Example
GET with headers → Ansible uri module
curl 'https://api.example.com/v1/users?page=2' \
-H 'Accept: application/json' \
-H 'Authorization: Bearer YOUR_TOKEN'- name: "GET https://api.example.com/v1/users?page=2"
ansible.builtin.uri:
url: "https://api.example.com/v1/users?page=2"
method: "GET"
headers:
"Accept": "application/json"
"Authorization": "Bearer YOUR_TOKEN"
return_content: true
register: response
- name: Show the response
ansible.builtin.debug:
msg:
- "{{ response.status }}"
- "{{ response.content }}"Common use cases
- Calling APIs during deployments
- Health checks and smoke tests in playbooks
- Registering servers with an external service
Converting curl to Ansible uri module
The ansible.builtin.uri module sends HTTP requests from a playbook. JSON bodies use body_format: json, and the response is registered so later tasks can use it.
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 uri module code. Options that have no uri module equivalent are listed under the editors rather than silently dropped.
Limitations
- 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 check the status code in Ansible?
The response is registered as response; use response.status. Add status_code: [200, 201] to the task to fail on anything else.
Why does the task fail on a 404?
The uri module expects 200 by default. Set status_code to the codes you accept.
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.