Home / Developer tools / SQL pretty print

SQL Pretty Print

Format a query and read it with line numbers and syntax colors. Keywords, functions, strings, numbers and comments each get a color, so that mistakes show up quickly.

Try:

Everything runs in your browser. Your SQL is not sent to our server.

What SQL pretty print gives you

The query is formatted first, with the same options as the SQL formatter. The result is then shown in a reading view with line numbers and syntax colors. The plain text of the result is what you copy, with no numbers and no markup.

What the colors mean

ColorMeaning
PurpleKeywords and data types, such as SELECT, JOIN, WHERE, INT and VARCHAR
GoldFunction calls, such as COUNT(), COALESCE() and NOW()
BlueStrings in single quotes
OrangeNumbers
Grey italicComments

Why colors help

  • A missing closing quote turns the rest of the query into one blue string, so you see it at once.
  • A missing closing comment mark makes the rest of the query grey.
  • A keyword used as a column name, such as a column called order or group, shows up in the keyword color.
  • A number that should be a string, such as a zip code without quotes, is easy to spot in the number color.

Line numbers

Line numbers help you talk about a query in a code review, a bug report or a chat: "the problem is on line 14". They also match the line numbers in error messages from some database tools, when you paste a query that has the same layout.

Options

Choose the dialect, indent, keyword case, comma position, and whether AND / OR and CASE use several lines. All of the options of the formatter work here.

See also the SQL beautifier, the SQL minifier and the SQL formatting guide. Other pretty print tools: HTML pretty print, CSS pretty print and JavaScript pretty print.

Frequently asked questions

What is SQL pretty print?

It formats a query and shows it in a reading view with line numbers and syntax colors, so that the structure and the mistakes are easy to see.

Are the line numbers copied with the code?

No. Copy gives you the clean formatted SQL with no line numbers and no color markup.

Which parts of the query get colors?

Keywords and types, function calls, strings, numbers and comments.

Does pretty print change my query?

No. Only the layout and the case of keywords change, and you can keep your own case.