How to use it

Static Binaries

java -jar JSQLFormatter.jar [-i <arg>] [-o <arg>] [-f <arg> | --ansi | --html]   [-t <arg> | -2 | -8]   [--keywordSpelling <arg>] [--functionSpelling <arg>] [--objectSpelling <arg>] [--separation <arg>] [--squareBracketQuotation <arg>] --squareBracketQuotation <arg>

Command Line Options (CLI)

--inputFile, -i <arg>

The input SQL file or folder.

--outputFile, -o <arg>

The out SQL file for the formatted statements.

--format, -f <arg>

The output-format [PLAIN* ANSI HTML RTF]


Output ANSI annotated text.


Output HTML annotated text.

--indentWidth, -t <arg>

The Indent Width [2 4* 8] -2 Indent with 2 characters. -8 Indent with 8 characters.

--keywordSpelling <arg>

Spelling of keywords. [UPPER* LOWER CAMEL KEEP]

--objectSpelling <arg>

Spelling of object names. [UPPER* LOWER CAMEL KEEP]

--functionSpelling <arg>

Spelling of function names. [UPPER* LOWER CAMEL KEEP]

--separation <arg>

Position of the field separator. [BEFORE* AFTER]

--squareBracketQuotation <arg>

Interpret Square Brackets “[]” as quotes instead of arrays. [AUTO* YES NO]


You can provide the SQL Statement as an argument to the program, e. g.

java -jar JSQLFormatter.jar "select * from dual;"


You can provide the formatting options as comment in front of the sql statement

-- @JSQLFormatter(indentWidth=8, keywordSpelling=UPPER, functionSpelling=CAMEL, objectSpelling=LOWER, separation=BEFORE)
SELECT 'something' FROM DUAL;


On Windows 10, you will need to active ANSI output first

Set-ItemProperty HKCU:\Console VirtualTerminalLevel -Type DWORD 1

Dynamic Libraries

import com.manticore.jsqlformatter.JSqlFormatter;

class Sample {
    public static void main(String[] args) {
        String formattedSql = JSqlFormatter.format("select * fromd dual;");