SQL to JSON Converter – Convert SQL Queries to JSON Online Free
Convert SQL query results or database tables to JSON format online free. Export MySQL, PostgreSQL, SQLite to JSON instantly.
Converted results will appear here
Convert SQL queries to JSON online free. Export MySQL, PostgreSQL, SQLite to JSON. Array of objects or NDJSON.
Convert SQL to JSON – Complete Guide
Transform your SQL query results into JSON (JavaScript Object Notation) – the standard format for web APIs and modern applications. Our SQL to JSON Converter supports all major SQL dialects and offers flexible output styles.
How It Works
You provide a SQL SELECT query or upload a .sql file. Our parser executes the query and converts each row into a JSON object. You can choose between array of objects, object with keyed rows, or newline-delimited JSON (NDJSON).
Supported SQL Dialects
| Database | Example Query |
|---|---|
| MySQL | SELECT id, name FROM users |
| PostgreSQL | SELECT * FROM products WHERE price > 100 |
| SQLite | SELECT name, age FROM customers |
Code Example & Output
-- Input SQL (MySQL)
SELECT id, product_name, price FROM inventory WHERE quantity > 0;
-- Output JSON (array of objects)
[
{"id": 1, "product_name": "Laptop", "price": 999.99},
{"id": 2, "product_name": "Mouse", "price": 19.99}
]
-- Output JSON (with root object)
{
"data": [
{"id": 1, "product_name": "Laptop", "price": 999.99},
{"id": 2, "product_name": "Mouse", "price": 19.99}
]
}
-- Output NDJSON (one JSON object per line)
{"id": 1, "product_name": "Laptop", "price": 999.99}
{"id": 2, "product_name": "Mouse", "price": 19.99}
Advanced Options
- Output style: array of objects, keyed object, NDJSON
- Root element: custom key name (e.g., "results")
- NULL handling: null, empty string, or omit key
- Pretty print: indentation level (2 spaces, 4 spaces, tab)
- JSONP callback: wrap in function call
- Date format: ISO 8601, timestamp, or custom strftime
Use Cases
- Generate JSON for REST APIs from legacy databases
- Export data to NoSQL databases like MongoDB
- Feed JSON into JavaScript frontend frameworks (React, Vue, Angular)
- Create configuration files from SQL tables
- Data exchange between microservices
For large result sets, NDJSON format is recommended as it allows streaming. Our tool handles up to 100,000 rows efficiently. Numbers are kept as JSON numbers (not quoted), booleans become true/false, and null becomes null.
Example with nested JSON: Use SQL JSON functions like JSON_OBJECT() in MySQL or jsonb_build_object() in PostgreSQL – our parser recognizes these and preserves the structure.
No registration, no watermarks, completely free.
Frequently Asked Questions
Everything you need to know about this tool