Skip to content
koducathome

cURL to SQL Converter

Convert curl commands to SQL code using PostgreSQL http, SQL Server or Oracle UTL_HTTP. Paste a command and the SQL snippet appears instantly — everything runs in your browser.

How to use this tool

Steps for using the cURL to Code.

  1. Copy a curl command — from API documentation, or from your browser's DevTools (Network tab → right-click a request → Copy as cURL (bash)).
  2. Paste it into Enter cURL command. The SQL PostgreSQL http code appears instantly; other SQL libraries (SQL Server, Oracle UTL_HTTP) are in the tabs above the code.
  3. Set up: Install the extension on the database server (packages such as postgresql-16-http, or build it from GitHub), then run CREATE EXTENSION http;. Some managed services don't offer it.
  4. Run it: Run the SQL in psql or any PostgreSQL client. Replace placeholders such as YOUR_TOKEN first, and check any notes under the editors for curl options that have no PostgreSQL http equivalent.

Example

GET with headers → SQL PostgreSQL http

curl command
curl 'https://api.example.com/v1/users?page=2' \
  -H 'Accept: application/json' \
  -H 'Authorization: Bearer YOUR_TOKEN'
SQL PostgreSQL http
-- Needs the pgsql-http extension: https://github.com/pramsey/pgsql-http
CREATE EXTENSION IF NOT EXISTS http;

SELECT status, content_type, content
FROM http((
  'GET',
  'https://api.example.com/v1/users?page=2',
  ARRAY[
    http_header('Accept', 'application/json'),
    http_header('Authorization', 'Bearer YOUR_TOKEN')
  ],
  NULL,
  NULL
)::http_request);

Common use cases

  • Calling webhooks or APIs from triggers and scheduled jobs
  • Loading API data straight into tables

Converting curl to SQL PostgreSQL http

The pgsql-http extension adds an http() function to PostgreSQL, so a query can call an API and return the status, headers and body as columns. The code builds an http_request with the method, URL, headers, content type and body.

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 PostgreSQL http code. Options that have no PostgreSQL http equivalent are listed under the editors rather than silently dropped.

Other libraries for SQL, each with its own page: SQL Server, Oracle UTL_HTTP.

Limitations

  • Only GET, POST, PUT, PATCH, DELETE and HEAD are supported.
  • The request runs inside the database session and blocks it until the API answers.
  • File uploads (curl -F) aren't supported.
  • 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

Where does the Content-Type header go?

In the fourth field of http_request, not in the headers array — pgsql-http sets it from there.

How do I read a JSON response?

Cast the content column: SELECT content::jsonb ->> 'name' FROM http(…);.

Can I use this on Amazon RDS or Azure?

Only where the provider supports the http extension — check its list of extensions. Otherwise, call the API from your application instead.

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.