Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More

sql-formatter

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sql-formatter

Format whitespace in a SQL query to make it more readable


Version published
Weekly downloads
306K
decreased by-35.25%
Maintainers
3
Weekly downloads
 
Created

What is sql-formatter?

The sql-formatter npm package is a library for formatting SQL queries. It supports various SQL dialects and provides a clean and readable output for SQL statements.

What are sql-formatter's main functionalities?

Basic SQL Formatting

This feature allows you to format a basic SQL query into a more readable format.

const sqlFormatter = require('sql-formatter');
const formattedSQL = sqlFormatter.format('SELECT * FROM table WHERE column = value');
console.log(formattedSQL);

Dialect-Specific Formatting

This feature allows you to format SQL queries according to specific SQL dialects like MySQL, PostgreSQL, etc.

const sqlFormatter = require('sql-formatter');
const formattedSQL = sqlFormatter.format('SELECT * FROM table WHERE column = value', { language: 'mysql' });
console.log(formattedSQL);

Custom Indentation

This feature allows you to customize the indentation used in the formatted SQL output.

const sqlFormatter = require('sql-formatter');
const formattedSQL = sqlFormatter.format('SELECT * FROM table WHERE column = value', { indent: '    ' });
console.log(formattedSQL);

Other packages similar to sql-formatter

FAQs

Package last updated on 31 Jan 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts