A SPARQL 1.1 query formatter for Node.js and the browser. Current version 1.0.2 formats SPARQL queries with customizable indentation and formatting modes (default, compact, turtle, JSON-LD). It supports both ESM imports and CommonJS require, and includes a CLI tool. Unlike ad-hoc formatters, it parses queries according to the SPARQL 1.1 spec, ensuring correctness. The package is stable with low release cadence, suitable for integration into query editors or pipelines.
npm install sparql-formatterNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Basic usage importing spfmt and formatting a SPARQL query with default and compact modes.
Use `npx sparql-formatter` or global install.
Use exactly 'default', 'compact', 'turtle', or 'jsonld'.
Set "type": "module" in package.json or use dynamic import().
Run `npm install sparql-formatter` and ensure import is from 'sparql-formatter'.