Keyboard Shortcuts

H - Show / hide this help window
Ctrl+F - Format SQL and display result
O - Show / hide options
T - Set focus on SQL input

Why not try sqlformat.org? Same app, refurbished interface, improved formatting (and a different domain).

API Documentation

DEPRECATED

This API is deprecated and will be removed sooner or later.
Please visit http://sqlformat.org/api/ for an improved version of the API with additional features.
Thanks!

Using the API for this application is pretty simple. Just send a POST request to

http://sqlformat.appspot.com/format/

Options

The POST request accepts various options to control formatting. Only the data option is required. All others are optional.

data
The SQL statement to format.
remove_comments
Set to 1 to remove comments.
keyword_case
How to convert keywords. Allowed values are 'lower', 'upper', 'capitalize'.
identifier_case
How to convert identifiers. Allowed values are 'lower', 'upper', 'capitalize'.
n_indents
An integer indicating the indendation depth.
right_margin
An integer indicating the maximum line length.
output_format
Transfer the statement into another programming language. Allowed values are 'python', 'php'

Example

Here's a example in Python:

#!/usr/bin/env python

import urllib
import urllib2

payload = (
    ('data', 'select * from foo join bar on val1 = val2 where id = 123;'),
    ('format', 'text'),
    ('keyword_case', 'upper'),
    ('reindent', True),
    ('n_indents', 2),
    )

response = urllib2.urlopen('http://sqlformat.appspot.com/format/',
                           urllib.urlencode(payload))
print response.read()

Download sqlformat_example_client.py