2. How to use it

2.1. 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>

2.1.1. 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]

--ansi

Output ANSI annotated text.

--html

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]

Note

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

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

Note

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;

Warning

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

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

2.2. Dynamic Libraries

import com.manticore.jsqlformatter.JSqlFormatter;

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