Skip to content

ksqlDB Playground

A shared console for drafting and reviewing ksqlDB statements against your Kafka cluster. Use it to prototype streams, tables, and push/pull queries, then share the working snippet with your team — everyone viewing this page sees the same buffer.

ksqlDB is the streaming SQL engine for Kafka. It lets you build stream-processing applications with familiar SQL syntax instead of writing low-level consumer/producer code.

Shared query console

Type or paste your ksqlDB statements below and click Run to publish them to the shared buffer. Clear empties it for everyone, and the buffer auto-clears 10 minutes after the last edit so stale experiments don't linger.

Empty

Shortcut

Press ++ctrl+enter++ (or ++cmd+enter++) inside the editor to run.

Published notesloading…

The panel above stays collapsed until you open it. Its contents are published through the API as Markdown — headings, lists, tables, and fenced code blocks are all rendered. See Publishing notes below.

Example statements

Get started by pasting one of these into the console above.

Create a stream over a topic

CREATE STREAM riders (id INT KEY, lat DOUBLE, lon DOUBLE)
  WITH (KAFKA_TOPIC='locations', VALUE_FORMAT='JSON', PARTITIONS=1);

Insert some events

INSERT INTO riders (id, lat, lon) VALUES (1, 37.7749, -122.4194);
INSERT INTO riders (id, lat, lon) VALUES (2, 40.7128,  -74.0060);

Push query — runs continuously

SELECT id, lat, lon
  FROM riders
  EMIT CHANGES;

Materialized table with aggregation

CREATE TABLE rider_counts AS
  SELECT id, COUNT(*) AS pings
  FROM riders
  GROUP BY id
  EMIT CHANGES;

Pull query — point lookup against a table

SELECT pings FROM rider_counts WHERE id = 1;

Publishing notes

The collapsible Published notes panel near the top of this page is filled through the API with Markdown of any length. Whatever you publish is rendered to HTML — headings, lists, tables, links, and fenced code blocks all resolve. It persists until overwritten or deleted, and every viewer sees the same content (refreshed automatically).

# publish Markdown straight from a file (raw body)
curl -s -X POST http://localhost:8000/api/blocks/notes \
  --data-binary @release-notes.md

# or inline as JSON
curl -s -X POST http://localhost:8000/api/blocks/notes \
  -H 'Content-Type: application/json' \
  -d '{"content": "## Heads up\n\n```sql\nSELECT * FROM riders EMIT CHANGES;\n```"}'

# read the raw Markdown back, or clear it
curl -s http://localhost:8000/api/blocks/notes
curl -s -X DELETE http://localhost:8000/api/blocks/notes

Any <details class="api-md" data-md-block="<name>"> element on a page becomes a live Markdown panel backed by /api/blocks/<name>, so you can add as many as you like.

Reading the shared scratchpad

The query buffer in the console above is itself readable over the API — handy for tooling, dashboards, or piping the current draft into the ksqlDB CLI:

# read the current shared scratchpad
curl -s http://localhost:8000/api/snippet
# -> {"content": "...", "updated_at": 1718800000.0, "remaining": 540}

# pull just the SQL text and run it
curl -s http://localhost:8000/api/snippet | python3 -c 'import sys,json; print(json.load(sys.stdin)["content"])'

remaining is the seconds left before the buffer auto-clears. updated_at is null and content is empty when the buffer has expired or is unset.

Running statements for real

To execute these against a live cluster, pipe the buffer into the ksqlDB CLI:

ksql http://localhost:8088

Or send a statement over the REST API:

curl -s -X POST http://localhost:8088/ksql \
  -H 'Content-Type: application/vnd.ksql.v1+json' \
  -d '{"ksql": "SHOW STREAMS;"}'

ksqlDB is part of the Apache Kafka ecosystem. See the ksqlDB documentation for the full statement reference.