Home › Developer Tools › SQL Online Compiler

SQL Online Compiler

Write SQL and run it on a real SQLite database right in your browser. Start from a sample company, store or school database, run several statements at once, then export results as CSV or download the whole database.

Last updated:

Ln 1, Col 1Ctrl + Enter runs all · select text to run only that part
Loading the SQLite engine…
Advertisement
Advertisement

How to use the SQL Online Compiler

  1. Pick a database: a sample company, online store or school, or an empty one. Its tables and columns appear on the left.
  2. Write SQL in the editor, or click an example query above it.
  3. Press Run SQL or Ctrl + Enter. To run just part of the script, select it first.
  4. Read the results. Each statement shows its rows, the rows it changed and how long it took. Errors mark the line.
  5. Export a result as CSV, or press Download .db to keep the database with your changes.

SQL quick reference (SQLite)

TaskSQL
Filter and sortSELECT name, salary FROM employees WHERE salary > 100000 ORDER BY salary DESC LIMIT 5;
Join two tablesSELECT e.first_name, d.name FROM employees e JOIN departments d ON d.id = e.department_id;
Keep rows without a match… FROM departments d LEFT JOIN employees e ON e.department_id = d.id
Aggregate per groupSELECT department_id, COUNT(*), AVG(salary) FROM employees GROUP BY department_id HAVING COUNT(*) > 2;
Rank within groupsRANK() OVER (PARTITION BY department_id ORDER BY salary DESC)
Named subquery (CTE)WITH big AS (SELECT * FROM orders WHERE total > 100) SELECT COUNT(*) FROM big;
Conditional valueCASE WHEN score >= 90 THEN 'A' WHEN score >= 80 THEN 'B' ELSE 'C' END
Datesdate('now'), strftime('%Y-%m', order_date), julianday(b) - julianday(a)
Join textfirst_name || ' ' || last_name
Replace NULLCOALESCE(manager, '(none)') or IFNULL(x, 0)
Insert or updateINSERT INTO t (id, n) VALUES (1, 'a') ON CONFLICT(id) DO UPDATE SET n = excluded.n;
Change and remove rowsUPDATE products SET stock = stock - 1 WHERE id = 3; DELETE FROM orders WHERE status = 'cancelled';

The sample databases

  • Company: departments, employees (with a manager_id that points back to employees, ideal for self joins), projects and the link table employee_projects. One intern has no department, so you can see how INNER and LEFT joins differ.
  • Online store: customers, products, orders with a status CHECK constraint, and order_items. Good for revenue totals, monthly reports and finding customers without orders.
  • School: students, courses and enrollments with scores, one of them still NULL. Practise averages, CASE grading, ranking and NOT EXISTS.

All data is fictional. Edit it freely: Reset data restores the original rows at any time.

SQLite in a nutshell

SQLite stores a whole database in a single file and is the most widely deployed database engine: it ships inside every major browser, phone operating system and countless desktop apps. Columns have a type affinity rather than a strict type, so a TEXT column can still hold a number unless you declare the table STRICT. A column declared INTEGER PRIMARY KEY becomes the row id and fills itself in automatically when you insert NULL or leave it out. Booleans are stored as 0 and 1, which is why SUM(status = 'cancelled') counts matching rows.

Frequently asked questions

Which SQL dialect does this compiler use?

SQLite 3, through sql.js, the official SQLite C code compiled to WebAssembly. It supports standard SELECT, joins, GROUP BY, subqueries, CTEs (WITH and WITH RECURSIVE), window functions such as RANK and ROW_NUMBER, UPSERT, JSON functions and date functions. Server features such as stored procedures, users and GRANT do not exist in SQLite.

Is my data saved?

The database lives in your browser's memory while the page is open. Reloading or switching databases resets it to the sample data, but your SQL text is remembered on this device. Press Download .db to keep a copy with all your changes, and open it again later with Open .db.

Can I practise MySQL or PostgreSQL queries here?

Most everyday SQL works the same: SELECT, WHERE, JOIN, GROUP BY, ORDER BY, LIMIT, INSERT, UPDATE and DELETE. Differences show up in data types, string functions and dates: SQLite uses || to join strings, strftime() and date() for dates, and has no ILIKE or SERIAL. Use INTEGER PRIMARY KEY for auto-increment ids.

How do I run several statements?

Separate them with semicolons and press Run. They run in order, and each statement that returns rows gets its own result table. If one fails, the statements before it have already run and the error shows where it stopped.

Are my queries or files uploaded?

No. SQLite runs entirely inside your browser tab. Your SQL, the sample data and any .db file you open never leave your device.

How large can a database be?

Databases are held in memory, so files of tens of megabytes work well on most computers. Very large files may be slow to open or exceed the memory available to the browser tab. The result grid shows the first 1,000 rows, while CSV export includes every row.

Why do I get 'no such column' when the column exists?

Usually because a string was written in double quotes. In SQL, 'single quotes' mark text values and "double quotes" mark names, so WHERE name = "Ann" looks for a column called Ann. Write WHERE name = 'Ann' instead.

Are all the tools on FreeToolCabin tested for quality and accuracy?

Yes! Every tool on our site undergoes automated Q/A testing in real browser environments to ensure high precision, correct output, and zero errors. If you happen to spot a bug or have a suggestion, please contact us at [email protected] and our team will review it right away.

Related tools

SQL Formatter & BeautifierFormat, beautify or minify SQL queries for MySQL, PostgreSQL and more.SQLite ViewerOpen .db and .sqlite files in your browser, browse tables and run SQL queries.CSV to SQL ConverterConvert CSV to SQL CREATE TABLE and INSERT statements for MySQL, PostgreSQL, SQLite or SQL Server.JSON to SQL ConverterConvert a JSON array of objects to CREATE TABLE and INSERT statements for MySQL, Postgres, SQLite.JSON to Excel ConverterTurn JSON into a styled .xlsx spreadsheet; nested arrays become their own linked sheets.JSON to CSVConvert JSON data to CSV for spreadsheets.CSV to JSONConvert CSV data to JSON with live preview.Excel to CSVConvert XLSX spreadsheets to CSV.CSV ViewerOpen a CSV or TSV file as a sortable, filterable table.Excel Viewer (XLSX / XLS)Open XLSX, XLS and ODS spreadsheets in your browser without Excel.Line Ending ConverterConvert text and files between CRLF, LF and CR line endings.Markdown to HTMLConvert Markdown to clean HTML with a live editor.XML to JSONConvert XML to JSON with validation.Text Encoding ConverterDetect and convert text file encodings like UTF-8, UTF-16 and Latin-1.JSON ViewerExplore JSON as a collapsible tree, search keys and values and copy any node's path.TTF to WOFF2 ConverterConvert TTF and OTF fonts to WOFF2 or WOFF and get a ready @font-face CSS snippet.Chmod CalculatorConvert Linux file permissions between checkboxes, octal (755) and symbolic (rwxr-xr-x) notation.JSON to TypeScriptGenerate TypeScript interfaces or types from JSON, with nested types and optional fields.Morse Code TranslatorTranslate text to Morse code and back, then play it as sound or a blinking light, or save a WAV.HTML Table GeneratorBuild HTML tables in an editable grid with styles, header rows, CSV import and live preview.Hex to Text ConverterConvert hex to text and text to hex with UTF-8 support and space, 0x, \x or comma formats.JSON to XML ConverterConvert JSON to well-formed XML with attributes, arrays and pretty print.JSON to YAML ConverterConvert JSON to clean YAML as you type, with indent, quoting and sort options.YAML to JSON ConverterConvert YAML to pretty or minified JSON, with errors pinned to the exact line.HTML to Markdown ConverterTurn HTML or pasted rich text into clean Markdown with tables and live preview.Markdown Table GeneratorBuild Markdown tables in a grid or paste from Excel/CSV, with alignment and preview.JSON ValidatorCheck JSON with the exact line and column of each error, fix tips and one-click auto-fix.Image to Base64Convert images to Base64 data URIs, CSS backgrounds and HTML img tags in your browser.Base64 to ImagePaste a Base64 string or data URI to preview, identify and download the image.JSON CompareCompare two JSON documents and see every added, removed and changed path.Hex to DecimalConvert hex to decimal instantly with steps and signed mode.Decimal to HexConvert decimal to hex instantly with steps and signed mode.Binary to DecimalConvert binary to decimal instantly with steps and signed mode.Decimal to BinaryConvert decimal to binary instantly with steps and signed mode.Two's Complement CalculatorDecimal to two's complement binary and back for 4-64 bits, with invert-and-add-1 steps.XML to CSV ConverterConvert XML to CSV: detects repeating records, flattens nested data, pick your columns.CSV to XML ConverterConvert CSV to well-formed XML with custom root and row names, escaping and pretty print.TOML to JSON ConverterConvert TOML to JSON and JSON to TOML with a full v1.0 parser and clear error lines.Remove Duplicates in ExcelFind and remove or highlight duplicate rows in XLSX or CSV files by the columns you choose.GeoJSON ViewerView GeoJSON on a map, inspect and edit properties, validate against RFC 7946 and export.GPX ViewerOpen GPX tracks on a map with distance, elevation profile, moving time, speed and splits.JSON Repair ToolFix broken JSON automatically: trailing commas, quotes, comments, truncated data, with a diff.Karnaugh Map SolverSolve 2–6 variable K-maps: click cells or enter minterms to get the minimal SOP or POS with groups.Merge Excel FilesCombine XLSX, XLS and CSV files into one workbook or append all rows into a single sheet.Parquet File ViewerOpen Apache Parquet files in your browser: schema, rows, filters and CSV or JSON export.Query CSV with SQLRun SQL on CSV, Excel, JSON and Parquet files in your browser with DuckDB. Join and export.Online Serial MonitorTalk to Arduino, ESP32 and USB serial devices in your browser: log, send, plot and save.Split Excel FileSplit an Excel sheet into several files by row count or by each value in a column, as ZIP.SQL Create Table GeneratorDefine columns, keys, defaults and indexes; get CREATE TABLE SQL for MySQL, Postgres and more.SQL IN Clause GeneratorTurn a pasted list into a SQL IN ('a','b') clause with quoting, dedupe and 1,000-item chunks.SQL to ER DiagramPaste CREATE TABLE statements and get an entity-relationship diagram with keys and links.XML to XSD GeneratorGenerate an XML Schema (XSD) from sample XML: types, occurrences, attributes and namespaces.XML ValidatorCheck if XML is well-formed, see the exact line and column of each error and pretty-print it.Wildcard Mask CalculatorConvert a subnet mask or CIDR to a wildcard mask for ACLs and OSPF, with range and binary.CSV to VCF ConverterConvert a contacts CSV into a vCard (.vcf) file, mapping columns to name, phone, email and more.CSV to YAML ConverterConvert CSV rows to a YAML list of mappings with type inference and delimiter detection.Endianness ConverterSwap byte order of 16, 32 and 64-bit hex values and see big- and little-endian integers and floats.Excel to SQL ConverterTurn an Excel sheet into CREATE TABLE and INSERT statements for MySQL, PostgreSQL, SQLite or SQL Server.Excel to VCF ConverterTurn an Excel contact list into a vCard .vcf file for iPhone, Android, Google or Outlook.File to C ArrayConvert any file into a C or C++ byte array header, like xxd -i, with const and PROGMEM options.Image to C ArrayConvert images to monochrome, RGB565 or RGB888 C arrays for OLED, LCD and TFT displays.JSON Merge ToolDeep-merge two or more JSON objects with array concat, replace or union and a conflict rule.JSONL to CSV ConverterConvert JSON Lines / NDJSON to CSV with flattened columns; streams large files locally.PHP Unserialize OnlineDecode PHP serialize() strings to JSON, a tree or print_r, and serialize JSON back to PHP.SQL Dialect ConverterTranslate SQL between MySQL, PostgreSQL, SQLite, SQL Server, Oracle, BigQuery and more.TSV to JSON ConverterTurn tab-separated data pasted from Excel or Sheets into a JSON array or keyed object.XLS to XLSX ConverterConvert old Excel 97-2003 .xls workbooks to modern .xlsx files in your browser, several at once.XML to Excel ConverterTurn repeating XML elements into an .xlsx spreadsheet with attributes and nested data as columns.
See all 129 Data & File Format Converters →