Toolvito

Works on this device. File exports run online.

Code Formatter

Paste code or open a file, and the page lays it out the standard way: indents, line breaks, spaces and quotes, without changing what the code does. Web languages and PHP are formatted in your browser; SQL, Python, C, C++, C#, Java, Go, shell scripts and Rust are formatted on the Toolvito server with the tools their developers use.

Format code

Language found: JavaScript.

Formatting…

Format on the server: SQL, Python, C, C++, C#, Java, Go, shell, Rust

Task
Format SQL (sqlglot)

The SQL in the box above is read by sqlglot for the database you choose and written again, laid out with one clause per line. It is never run. It can also be written for another database.

More options

When you run a task here, Toolvito receives the information you submit for processing. Download the result within one hour after the job finishes. Choose Delete files now to request earlier removal. The hourly cleanup normally removes files within one to two hours after completion.

How to format code

  1. Paste your code into the box, or press Or open a code file from your device.
  2. Leave Language on Find out from the code, or choose the language.
  3. Choose the indent (2 or 4 spaces, or tabs) and the line width, then press Format.
  4. Press Copy or Download to use the formatted code.
  5. For SQL, Python, C, C++, C#, Java, Go, shell scripts or Rust, use the matching server box below the formatter: it takes the code from the same box.

Languages and the formatter used

  • JavaScript (also JSX and Node.js), TypeScript, JSON, CSS, SCSS, Less, HTML, Markdown, YAML and GraphQL: Prettier 3.9.10, the formatter most web projects use, running in your browser. Code Prettier cannot read is not changed: the error shows the line and column.
  • XML and SVG: one element per line, indented by depth; an element that holds only text stays on one line. Comments, CDATA and the declaration are kept.
  • SQL: sqlglot on the Toolvito server reads each statement for the database you choose (PostgreSQL, MySQL, SQL Server, Oracle, SQLite, BigQuery, Snowflake and 13 more) and writes it again laid out. It can also write it for another database.
  • PHP (also with HTML around it): the Prettier PHP plugin, in your browser.
  • Python: black, the formatter most Python projects use, on the Toolvito server. Black reads the code but never runs it.
  • C, C++, C# and Java: clang-format with one of its built-in styles (LLVM, Google, Chromium, Mozilla, WebKit, Microsoft or GNU), your indent and line width, on the server.
  • Go: gofmt; shell scripts (bash, POSIX sh, mksh): shfmt; Rust: rustfmt. All on the server; the code is parsed and printed, never built or run.
  • Ruby, Swift, Kotlin, PowerShell, Lua, Dart, Scala and Perl are not formatted here.

Worked example

The JavaScript line function add(a,b){return a+b} becomes three lines: function add(a, b) {, then return a + b; indented by two spaces, then }. Only spaces, line breaks and the semicolon are added, so the function works the same.

Limits you should know

  • Formatting changes the layout, not the meaning: it does not find bugs. Code with a syntax error is refused, not partly formatted.
  • Find out from the code looks at how the code starts and at a few typical words. When it guesses wrong, choose the language.
  • Prettier and black have few settings on purpose. Choices outside them, such as where braces go, cannot be changed.
  • The formatter uses up to about 2 MB of code; very large files can make the page slow.

Privacy

JavaScript, TypeScript, JSON, CSS, HTML, Markdown, YAML, GraphQL and XML are formatted in your browser and not uploaded. Only when you use the server box is the code in the box sent to the Toolvito server, to format SQL or Python there. Download the result within one hour after the job finishes. Choose Delete files now to request earlier removal. The hourly cleanup normally removes files within one to two hours after completion.

Related tools