Skip to main content
Allows formatting input queries. Keys:
  • --help or-h — Produce help message.
  • --query — Format queries of any length and complexity.
  • --hilite or --highlight — Add syntax highlight with ANSI terminal escape sequences.
  • --oneline — Format in single line.
  • --max_line_length — Format in single line queries with length less than specified.
  • --wrap_width — Wrap multiline queries at the specified display width. Wrapping is disabled by default (0). Queries formatted in a single line by --oneline or --max_line_length are not wrapped.
  • --comments — Keep comments in the output.
  • --quiet or -q — Just check syntax, no output on success.
  • --multiquery or -n — Allow multiple queries in the same file.
  • --obfuscate — Obfuscate instead of formatting.
  • --seed <string> — Seed arbitrary string that determines the result of obfuscation.
  • --backslash — Add a backslash at the end of each line of the formatted query. Can be useful when you copy a query from web or somewhere else with multiple lines, and want to execute it in command line.
  • --semicolons_inline — In multiquery mode, write semicolons on last line of query instead of a new line.
If a function call, an array or tuple, an AND/OR chain, a window definition or the column list of INSERT does not fit into the width, its elements start on new lines with deeper indentation. Function arguments and array elements that are plain values (column names and literals) are packed several per line. Queries whose formatted lines already fit are not changed. The width is a soft limit: strings, identifiers and other indivisible fragments can exceed it. Unicode character widths are taken into account. Comments retained by --comments and data following INSERT ... VALUES are not wrapped.

Examples

  1. Formatting a query:
Query
Response
  1. Highlighting and single line:
Query
Response
  1. Multiqueries:
Query
Response
  1. Obfuscating:
Query
Response
Same query and another seed string:
Query
Response
  1. Adding backslash:
Query
Response
  1. Wrapping long expressions:
Query
Response