{"meta":{"title":"query format","intro":"Autoformat QL source code.","product":"Security and code quality","breadcrumbs":[{"href":"/en/code-security","title":"Security and code quality"},{"href":"/en/code-security/reference","title":"Reference"},{"href":"/en/code-security/reference/code-scanning","title":"Code scanning"},{"href":"/en/code-security/reference/code-scanning/codeql","title":"CodeQL"},{"href":"/en/code-security/reference/code-scanning/codeql/codeql-cli-manual","title":"CodeQL CLI manual"},{"href":"/en/code-security/reference/code-scanning/codeql/codeql-cli-manual/query-format","title":"query format"}],"documentType":"article"},"body":"# query format\n\nAutoformat QL source code.\n\n> [!NOTE]\n> This content describes the most recent release of the CodeQL CLI. For more information about this release, see https://github.com/github/codeql-cli-binaries/releases.\n>\n> To see details of the options available for this command in an earlier release, run the command with the <span style=\"white-space: nowrap;\">`--help`</span> option in your terminal.\n\n## Synopsis\n\n```shell copy\ncodeql query format [--output=<file>] [--in-place] [--backup=<ext>] <options>... -- <file>...\n```\n\n## Description\n\nAutoformat QL source code.\n\n## Options\n\n### Primary Options\n\n#### `<file>...`\n\nOne or more `.ql` or `.qll` source files to autoformat. A dash can be\nspecified to read from standard input.\n\n#### `-o, --output=<file>`\n\nWrite the formatted QL code to this file instead of the standard output\nstream. Must not be given if there is more than one input.\n\n#### `-i, --[no-]in-place`\n\nOverwrite each input file with a formatted version of its content.\n\n#### `--[no-]check-only`\n\nInstead of writing output, exit with status 1 if any input files\n_differ_ from their correct formatting. A message telling which files\ndiffered will be printed to standard error unless you also give `-qq`.\n\n#### `-b, --backup=<ext>`\n\nWhen writing a file that already exists, rename the existing file to a\nbackup by appending this extension to its name. If the backup file\nalready exists, it will be silently deleted.\n\n#### `--no-syntax-errors`\n\nIf an input file is not syntactically correct QL, pretend that it is\nalready correctly formatted. (Usually such a file causes the command to\nterminate with an error message).\n\n### Common options\n\n#### `-h, --help`\n\nShow this help text.\n\n#### `-J=<opt>`\n\n\\[Advanced] Give option to the JVM running the command.\n\n(Beware that options containing spaces will not be handled correctly.)\n\n#### `-v, --verbose`\n\nIncrementally increase the number of progress messages printed.\n\n#### `-q, --quiet`\n\nIncrementally decrease the number of progress messages printed.\n\n#### `--verbosity=<level>`\n\n\\[Advanced] Explicitly set the verbosity level to one of errors,\nwarnings, progress, progress+, progress++, progress+++. Overrides `-v`\nand `-q`.\n\n#### `--logdir=<dir>`\n\n\\[Advanced] Write detailed logs to one or more files in the given\ndirectory, with generated names that include timestamps and the name of\nthe running subcommand.\n\n(To write a log file with a name you have full control over, instead\ngive `--log-to-stderr` and redirect stderr as desired.)\n\n#### `--common-caches=<dir>`\n\n\\[Advanced] Controls the location of cached data on disk that will\npersist between several runs of the CLI, such as downloaded QL packs and\ncompiled query plans. If not set explicitly, this defaults to a\ndirectory named `.codeql` in the user's home directory; it will be\ncreated if it doesn't already exist.\n\nAvailable since `v2.15.2`."}