Skip to content

Sql To Json API

POST https://api.findutils.com/api/tools/sql-to-json/execute

Read rows out of SQL INSERT statements (mysqldump, SQLite dump, pg_dump made with --inserts; PostgreSQL COPY blocks are not read) and return JSON: an array of objects, or an object keyed by table when the dump holds rows for more than one table. The SQL is parsed as text — nothing is executed. Column names come from the INSERT column list, then from a CREATE TABLE in the same input, then from positions (column_1, column_2, ...). NULL becomes null, unquoted TRUE/FALSE become booleans, unquoted numbers become JSON numbers unless a double cannot hold them exactly (beyond ±9007199254740991 or more than 15 significant digits), in which case they stay strings. Quoted values stay strings; with coerce_numbers a quoted column becomes numbers only when every quoted value in that column writes back as the same text, so a column holding '007' stays all strings. Functions and keywords such as NOW() or DEFAULT are not evaluated: their SQL text is kept as a string and listed in notes. Hex and bit literals stay as text. An INSERT ... SELECT has no literal rows and is listed in skipped rather than guessed at.

Request body

application/json
  • sql

    string required

    SQL dump text containing INSERT statements.

  • group_by_table

    string optional

    'auto' returns an object keyed by table only when more than one table has rows; 'always' always keys by table; 'never' returns one flat array. One of auto · always · never. Default "auto".

  • coerce_numbers

    boolean optional

    Turn QUOTED numbers into JSON numbers, decided per column: a column converts only when every quoted value in it is a canonical number (such as '42' or '-3.5'), so a column holding '007', '1.50', '+3' or '1e5' stays all strings. Unquoted numbers are always numbers. Default true.

  • include_table_key

    boolean optional

    In a flat array, add a "__table" field naming each row's table. Ignored when grouped. Default false.

  • indent

    integer optional

    Spaces of indentation in the json string. 0 gives minified output. One of 0 · 2 · 4. Default 2.

  • table

    string optional

    Return only this table. Default: every table found.

  • max_rows

    integer optional

    Stop after this many rows per table. Default 50000, maximum 200000. Default 50000.

Example arguments

Verified
{
  "sql": "INSERT INTO people (id, name, active) VALUES (1, 'Ada', TRUE), (2, NULL, FALSE);"
}