K-Lab

JSON Query

Loading...

SQL Query
Syntax Guide|⌘+Enter to run
Query History (0)

Loading...

Powered byDuckDB-Wasm
About this tool

SQL queries on JSON files

JSON Query lets you load one or more JSON files directly into your browser and query them with standard SQL. The tool is powered by DuckDB-Wasm, a high-performance analytical SQL engine compiled to WebAssembly. Your data never leaves your browser — all processing happens locally.

Each loaded JSON file becomes a named table. If you drop a file called products.json, you can immediately query it with SELECT * FROM products. Multiple files can be joined together using standard SQL JOINs, making it easy to explore relationships between datasets.

Auto-flattening nested JSON

Many real-world JSON exports contain deeply nested structures — objects keyed by ID, nested data fields, metadata wrappers. This tool automatically detects common patterns like product_by_id maps and flattens them into queryable rows. Nested data objects are promoted to top-level columns so you can write simple queries without navigating complex paths.

Common query patterns

  • SELECT DISTINCT type FROM productsGet unique values from a column
  • SELECT type, COUNT(*) FROM products GROUP BY typeCount records by category
  • SELECT * FROM products p JOIN services s ON ...Combine data from multiple files
  • DESCRIBE productsInspect table schema (column names and types)

Frequently Asked Questions

How do I JOIN two JSON files?

Drop both files into the data sources zone. Each file becomes a named table (e.g., products and services). Then write a standard SQL JOIN: SELECT * FROM products p JOIN services s ON p.service_id = s.id. DuckDB supports all JOIN types including LEFT, RIGHT, FULL OUTER, and CROSS JOINs. If your files have nested ID maps, they will be automatically flattened into queryable rows.

What SQL operations are supported?

This tool is powered by DuckDB, which supports a full PostgreSQL-compatible SQL dialect. You can use SELECT, WHERE, JOIN (all types), GROUP BY, DISTINCT, ORDER BY, LIMIT, HAVING, UNION, subqueries, Common Table Expressions (WITH/CTE), window functions (ROW_NUMBER, RANK, LAG, LEAD), aggregate functions (COUNT, SUM, AVG, MIN, MAX), and string functions (LIKE, ILIKE, REGEXP). You also have access to DESCRIBE to inspect table schemas.

Is my data safe? Does it leave my browser?

Your data never leaves your browser. The SQL engine (DuckDB-Wasm) runs entirely client-side using WebAssembly. No data is sent to any server. Your loaded JSON files are stored in your browser's IndexedDB for persistence across page reloads, and query history is stored in localStorage. You can clear all stored data at any time using the Clear All Data button.

What happens with nested JSON structures?

The tool automatically detects common nesting patterns. If your JSON contains a map of objects keyed by ID (like product_by_id: { uuid1: { data: {...} }, uuid2: {...} }), it will be flattened into a table of rows with each nested data field promoted to a top-level column. Nested data objects are promoted to top-level columns so you can write simple queries without navigating complex paths.

How large can my JSON files be?

DuckDB-Wasm uses a columnar vectorized execution engine designed for analytical workloads, so it handles large datasets efficiently. Files up to 50-100MB work well in most browsers. Performance depends on your device's available memory. For very large datasets, consider filtering or limiting your queries. The results table displays up to 1,000 rows at a time — add LIMIT to your query to control output size.