A formal grammar for Overpass Query Language in W3C EBNF notation, the same notation used by the XML 1.0 specification.
The grammar is useful for:
- Generating queries — use it as a reference for what combinations of syntax are valid when building tools that produce Overpass QL
- Validating queries — check whether a query is syntactically valid before sending it to the API
- Browsing the language — the Railroad Diagram Generator renders the grammar as interactive railroad diagrams, which may be easier to read than the raw EBNF
Paste the contents of overpassql.ebnf into the Railroad Diagram
Generator to browse the grammar visually or check
it for errors. The REx Parser Generator accepts
the same notation and can produce a parser if needed.
Transformations to other EBNF-like grammars should be relatively straightforward if you plan to use a different parser implementation.
Please do not use this grammar to abuse public Overpass servers by sending large volumes of automated queries. If you have a use case that depends on a lot of Overpass traffic, consider running your own local Overpass instance using the original source code or one of the container images.
The grammar covers features documented in the Overpass QL Language Reference, Overpass QL Language Guide, and Overpass API Blog. These sources are not always reliable, so the grammar has been verified against the Overpass API source code and tested against a live instance running v0.7.62.11. Features accepted by the implementation but absent from the documentation are excluded.
If you find an error or a gap, please open an issue.