Developer Tools
PromQL Formatter
Format a PromQL query into readable indented lines or one tidy line, and see its structure explained: selectors, matchers, functions, and operators. No signup.
PromQL formatter and explainer
Examples
Paste a query from a Grafana panel, a recording rule, or an alerting rule. The query is parsed into a syntax tree and re-emitted; it is not executed, and no data is fetched.
Formatted
sum by (job) (rate(http_requests_total{status=~"5..", env="prod"}[5m]))One line
sum by (job) (rate(http_requests_total{status=~"5..", env="prod"}[5m]))A normalized single line: consistent spacing around operators and after commas, ready to paste back into a panel or rule.
What this query does
Aggregates a vector with "sum" grouped by job.
Metrics
http_requests_totalFunctions
raterangeLabel matchers
statusmatches regex"5.."envequals"prod"
Aggregations
sumby (job)
Time modifiers
- Range
[5m]
PromQL quick reference
The structure this tool parses, summarized in one place.
Selectors
metric{label="v"}picks series by label.=!==~!~are the matchers.[5m]makes it a range vector.
Operator precedence
^(right associative)* / % atan2+ -== != <= < >= >and unlessor
Aggregations
sum by (job) (...)keeps the job label.without (instance)drops a label instead.- sum, avg, min, max, count, topk, quantile, and more.
Modifiers
offset 1hshifts the lookback back in time.@ end()pins evaluation to a fixed instant.[30m:1m]is a subquery range and step.
This tool formats and explains query text. It does not connect to a Prometheus server, evaluate the query, or return time series. To read a scraped /metrics body, use the Prometheus Metrics Parser instead.
How to use
- Paste a PromQL query into the box, or load one of the examples to see the format.
- Read the formatted output: a multi-line version with each argument and operator on its own line, and a single-line version with normalized spacing.
- Use the copy buttons to copy either the indented query or the one-line query.
- Open the explanation to see the metrics, label matchers, functions (tagged instant or range), aggregations, operators, and time modifiers.
- If the query cannot be parsed, read the message and the caret, which points at the character where parsing stopped, then fix the bracket, quote, or comma.
- Use Clear to empty the box and start over. The query stays in your browser and is never uploaded.
About this tool
PromQL Formatter takes a PromQL query, the language Prometheus, Thanos, Cortex, Mimir, and VictoriaMetrics share and the language behind every Grafana panel, recording rule, and alerting rule, and makes it readable. PromQL is almost always written on a single line, and once a query nests a rate inside an aggregation inside a histogram_quantile, with label matchers, a range, an offset, and a binary operator joining two vectors, that single line is genuinely hard to follow. This tool parses the query into a syntax tree and re-emits it two ways: a multi-line form with consistent indentation that puts each function argument and each side of a binary operator on its own line, and a normalized single line with even spacing around operators and after commas. The parser is the real thing, not a set of regular expressions. It tokenizes the query with the PromQL lexer rules, handling single, double, and backtick raw strings, numbers in decimal, hex, and scientific notation, the special values Inf and NaN, durations like 5m and 1h30m, the four label match operators (=, !=, =~, !~), the @ modifier, and the offset keyword. It then parses with the correct operator precedence: six levels, where exponentiation binds tightest and is the only right associative operator, then multiplication, division, modulo, and atan2, then addition and subtraction, then the comparison operators, then and and unless, and finally or. Because precedence is respected, the formatted output groups operands the way Prometheus actually evaluates them, which is often the first thing that clears up a confusing query. Alongside the formatting, the tool explains the query in plain language. It labels the root as an aggregation, a binary operation, a function call, or a selector, then lists every metric, every label matcher with its match type spelled out, every function tagged as an instant-vector or range-vector function (so you can see at a glance whether a rate has the range it needs), every aggregation with its by or without grouping, every binary operator with its bool modifier and on, ignoring, group_left, or group_right vector matching, and every range, offset, @ modifier, and subquery. When a function name is not one of the documented Prometheus built-ins, it is flagged as a likely typo rather than silently accepted. When the query does not parse, the tool reports the reason and points a caret at the exact character where parsing stopped, which makes a missing bracket, an unquoted matcher value, or a stray comma quick to find. One honest limit, stated plainly: this is a formatter, an explainer, and a syntax checker, not a Prometheus server. It does not connect to a target, evaluate the query, compute rates over real samples, or return any time series; it works only on the query text you paste. To read the metrics a /metrics endpoint returns, the Prometheus Metrics Parser is the companion tool. Everything here runs locally in your browser with a hand-written tokenizer and parser, so the queries you paste are never uploaded, fetched, or logged.
Free to use. Works in your browser. No signup, no login.
Related tools
You may also like
Prometheus Metrics Parser
Read /metrics exposition text into metric families with labels and values, export JSON or NDJSON, or build a valid metric line.
Open tool
DeveloperLogfmt Parser and Formatter
Parse logfmt to JSON or NDJSON and emit clean logfmt from JSON, NDJSON, or rows.
Open tool
DeveloperInfluxDB Line Protocol Parser
Read InfluxDB and Telegraf line protocol into typed points with tags and fields, export JSON or NDJSON, or build a valid line.
Open tool
DeveloperSQL Formatter
Pretty print SQL with configurable keyword case, indent, and comma style.
Open tool
DeveloperRegex Explainer
Plain English, token-by-token breakdown of any JavaScript regular expression.
Open tool
DeveloperCrontab Explainer
Translate any crontab to plain English with a field breakdown and next-run preview.
Open tool