pipr.tools
Pipes
Clean Email Strip formatting from pasted email for clean plain text Clean AI Output Clean plain text from ChatGPT or AI output Decode & Format JWT Decode a JWT and pretty-print header and payload Word Frequency Count word frequency in text

sql-format Format SQL queries

⟐ Data
Input0 chars
Output0 chars

Flags

--dialect select: sql | mysql | postgresql | mariadb | bigquery | sqlite | transactsql | plsql default: sql

Examples

Format a SQL query with proper indentation

Usage
"SELECT u.name, u.email FROM users u JOIN orders o ON u.id = ..." | sql-format

Clean up a messy query from a support ticket

Usage
"select * from customers where status='active' and plan in ('..." | sql-format

Format a SQL insert statement for documentation

Usage
"INSERT INTO events (name, date, location) VALUES ('Launch Pa..." | sql-format
View source
async (input, opts = {})=>{
                try {
                    const { format } = await import('sql-formatter').then(async (m)=>{
                        await m.__tla;
                        return m;
                    });
                    return format(input, {
                        language: opts.dialect || "sql"
                    });
                } catch (e) {
                    return `Error: ${e.message}`;
                }
            }