• Start

Formatter

SurrealQL Formatter

The surqlfmt command automatically formats SurrealQL files for consistent style and readability.

The surqlfmt tool reformats .surql files to follow a consistent style. It adjusts whitespace, indentation, and keyword casing so that SurrealQL code is easy to read and review.

The tool can be installed through a single npm install command:

npm install -g @surrealdb/surql-fmt

The tool outputs the reformatted file by default, and when the --write flag is passed in will reformat a .surql file in place.

# Format a single file
surqlfmt ./query.surql

# Check if files are formatted
surqlfmt --check ./src/**/*.surql

# Format from stdin
cat query.surql | surqlfmt --stdin

# Configure indentation and line length
surqlfmt --indent 4 --indent-char tab --max-line-length 120 *.surql

# Write files in-place
surqlfmt --write ./src/**/*.surql
  • Before committing — run surreal fmt on any .surql migration or seed files to keep diffs clean.

  • In CI — add a formatting check to catch inconsistencies early.

  • During development — pipe ad-hoc queries through the formatter for readability.

For the full list of command-line options, see the CLI reference.

Was this page helpful?