Skip to content
Guide · Run SQL in your browser

PostgreSQL Online: Run Postgres Queries in Your Browser

This PostgreSQL online playground runs actual Postgres, compiled to WebAssembly by the PGlite project, inside your browser. Postgres-only syntax such as JSONB operators, generate_series, DISTINCT ON and FILTER works as it does on a server, with no installation and no account.

Real PostgreSQL running in your browser through PGlite (Postgres compiled to WebAssembly). The engine is about 17 MB and loads from the jsDelivr CDN the first time you press Run.

Examples:
Sample data: tables and columns

Loads with the engine.

Facts on this page checked 8 October 2026 against the official documentation. Versions covered: PGlite 0.5.8 (reports PostgreSQL 18.3). Next review due April 2027. The playground runs entirely in your browser; nothing you type or open is sent to CodeWithSQL.
Short answer
  • The engine is PGlite 0.5.8, a WebAssembly build of PostgreSQL; SELECT version(); reports PostgreSQL 18.3.
  • It loads from the jsDelivr CDN the first time you press Run (about 17 MB), so the first run takes longer than later ones.
  • Sample shop and HR databases are loaded; Reset data restores them, and everything resets when you reload the page.
  • Queries run on your device. Nothing you type is sent to CodeWithSQL.
  • It is a single-user database in a browser tab, not free PostgreSQL hosting that an application can connect to.
How we know: Written from the playground's own code and the official PGlite and PostgreSQL documentation, checked on 8 October 2026. The example queries were written for the sample shop data.

How to run PostgreSQL online here

  1. Press Run (or Ctrl+Enter, Cmd+Enter on a Mac). The first time, the status line says it is loading PostgreSQL, which is about 17 MB from the jsDelivr CDN; the sample data is created once it has started.
  2. Use the Examples buttons for Postgres features, or type your own SQL. Several statements can run at once; each one that returns rows gets its own table, showing up to 1,000 rows.
  3. Download CSV saves the last result. Copy share link puts the query in the URL after #q=; nothing is stored on a server, and the link fills the editor without running it.
  4. Sample data switches between the shop and HR databases, and Reset data drops your changes.

The shop data has customers(customer_id, name, email, country, signup_date), products(product_id, name, category, price), orders(order_id, customer_id, order_date, status, total) and order_items(order_id, product_id, quantity, unit_price). The HR data has departments(dept_id, name, location) and employees(emp_id, name, dept_id, manager_id, job_title, salary, hire_date).

PostgreSQL queries to try

These use the shop data and syntax that SQLite does not have, so they show the difference from the SQLite-based editor.

PostgreSQL: orders per day, including days with none (generate_series)
SELECT d::date AS day, COUNT(o.order_id) AS orders
FROM generate_series(DATE '2026-02-01', DATE '2026-02-12', INTERVAL '1 day') AS d
LEFT JOIN orders o ON o.order_date = d::date
GROUP BY d
ORDER BY d;
PostgreSQL: each customer's largest order (DISTINCT ON)
SELECT DISTINCT ON (customer_id) customer_id, order_id, order_date, total
FROM orders
ORDER BY customer_id, total DESC;
PostgreSQL: monthly orders with a FILTER clause and date_trunc
SELECT date_trunc('month', order_date)::date AS month,
       COUNT(*) AS orders,
       SUM(total) FILTER (WHERE status = 'delivered') AS delivered_revenue
FROM orders
GROUP BY 1
ORDER BY 1;
PostgreSQL: products each customer bought (string_agg)
SELECT c.name, string_agg(DISTINCT p.name, ', ' ORDER BY p.name) AS products
FROM customers c
JOIN orders o ON o.customer_id = c.customer_id
JOIN order_items oi ON oi.order_id = o.order_id
JOIN products p ON p.product_id = oi.product_id
GROUP BY c.name
ORDER BY c.name;

Limitations compared with a PostgreSQL server

  • Single user. The PGlite project states that PGlite is single user and single connection. There are no roles to log in as and no other clients to connect.
  • Ephemeral. The playground runs PGlite as an in-memory database, so your tables are lost on reload. PGlite can persist to IndexedDB, but this page does not use that option.
  • Version. PGlite 0.5.8 reports PostgreSQL 18.3; the PostgreSQL project's current minor release for version 18 is 18.6. Minor releases contain fixes, not new syntax.
  • Extensions. Only the core server is loaded, so extensions such as PostGIS or pgvector are not available here.
  • First load. The engine download is large, so use a fast connection the first time.

If you need a PostgreSQL server that an application can reach, see our guide to free PostgreSQL hosting, or install PostgreSQL locally. Choosing between engines? See MySQL vs PostgreSQL and SQLite vs PostgreSQL.

Privacy

PGlite runs inside your browser tab. The engine files come from the jsDelivr CDN, but your queries and results stay on your device and are not sent to CodeWithSQL or to the CDN. A share link contains the query text, so anyone with the link can read it.

For structured practice, try the SQL exercises or the SQL beginner course.

Frequently asked questions

Is this real PostgreSQL?

Yes. PGlite is PostgreSQL compiled to WebAssembly, and the PGlite documentation notes that it does not use a Linux virtual machine. SELECT version(); shows the version it is built from.

Is it free PostgreSQL hosting?

No. The database exists only in your browser tab while the page is open. For a server you can connect to, use a hosted service or install PostgreSQL.

Why is the first run slow?

The browser downloads the PostgreSQL engine (about 17 MB) from the jsDelivr CDN and starts it. Later runs on the same page reuse the running database.

Can I use JSONB?

Yes. Try the JSONB example button, which reads a field with the ->> operator.

Does my data persist?

No. Reloading the page or pressing Reset data starts again from the sample data. Save queries with Copy share link and results with Download CSV.

Sources

Checked 8 October 2026.

How we research tool pages: our editorial method. The engines are open-source projects credited on each page.

Want structured practice?

Work through real problems with hints and solutions, or follow the beginner course.