Run XQuery online

A browser-based XQuery 3.1 workbench: write FLWOR expressions, construct new elements, and see the serialized result immediately. No server, no install, no BaseX setup — the engine runs in your tab, so the document you are querying stays on your machine.

Example

XQuery 3.1 on the Music Playlist sample:

<library-summary albums="{count(//album)}">{
  for $a in //album
  let $secs := sum(
        for $t in $a/tracks/track
        let $p := tokenize($t/@duration, ':')
        return number($p[1]) * 60 + number($p[2])
      )
  order by $secs descending
  return <album title="{string($a/title)}" artist="{string($a/artist)}"
                tracks="{count($a/tracks/track)}"
                runtime="{xs:integer($secs) idiv 60}m {xs:integer($secs) mod 60}s">{
    for $t in $a/tracks/track
    where number(tokenize($t/@duration, ':')[1]) >= 5
    return <long-track duration="{$t/@duration}">{string($t)}</long-track>
  }</album>
}</library-summary>

Reshapes the playlist into a brand-new report: it parses each track's mm:ss duration into seconds, totals the runtime per album, sorts albums by longest runtime, and nests the tracks over five minutes inside each album element.

Open it in the Sandbox

What XQuery adds over XPath

XQuery 3.1 is a superset of XPath 3.1 — every valid XPath expression is also a valid XQuery. What XQuery adds is the ability to shape output: FLWOR expressions (for, let, where, order by, return), direct element and attribute constructors, a prolog for namespace and function declarations, and typeswitch.

That is why a bare path like //album runs fine in XQuery mode: it is the XPath subset doing its job. Wrap it in a constructor and you are transforming rather than selecting.

Built for real work, not just snippets

The XQuery mode has the same tooling as XPath mode, plus a few things specific to writing longer queries.

  • Line numbers and inline error location in the query editor.
  • Format and wrap toggles for the query, document, and result panes.
  • Saved Queries that remember the document and namespaces the query was written against.
  • Console, Columns, and Quadrant layouts, switchable by keyboard.
  • Use the result of one query as the document for the next, in one click.
  • AI diagnostics that explain a failing query and propose a fix.

Engine and limits

Evaluation uses FontoXPath, a conformant pure-JavaScript XPath 3.1 / XQuery 3.1 engine. Updating expressions, XQuery modules, and fn:transform (XSLT) are outside its scope — the engine-support reference lists what is unsupported and gives a portable rewrite for each.

Very large documents stay usable: parsed documents are cached and live preview relaxes automatically past a few megabytes so typing never blocks on a re-parse.

Keep going