{"library":"prettier-plugin-sql-cst","title":"prettier-plugin-sql-cst","description":"A Prettier plugin for SQL that uses sql-parser-cst and the actual Prettier formatting algorithm (Wadler-Leijen). It adapts formatting based on expression length, sticking to one style with minimal configuration options. The plugin supports multiple SQL dialects: SQLite, BigQuery, PostgreSQL, MySQL, and MariaDB (some experimental). It parses and formats SQL code inside CREATE FUNCTION/PROCEDURE bodies (PostgreSQL). Current stable version is 0.19.3, with semi-regular releases (every few weeks). TypeScript types are shipped. Key differentiators vs other SQL formatters: uses Prettier's algorithmic line splitting for consistency, preserves syntax elements, and formats embedded languages.","language":"javascript","status":"active","last_verified":"Sat Apr 25","install":{"commands":["npm install prettier-plugin-sql-cst"],"cli":{"name":"prettier","version":null}},"imports":["import prettierPluginSqlCst from 'prettier-plugin-sql-cst'","// In .prettierrc: { \"plugins\": [\"prettier-plugin-sql-cst\"], \"overrides\": [{ \"files\": [\"*.sql\"], \"options\": { \"parser\": \"sqlite\" } }] }","// In .prettierrc: { \"plugins\": [\"prettier-plugin-sql-cst\"], \"overrides\": [{ \"files\": [\"*.sql\"], \"options\": { \"parser\": \"bigquery\" } }] }"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"// Install dependencies\n// npm install --save-dev prettier prettier-plugin-sql-cst\n\n// Create a .prettierrc.json file:\n{\n  \"plugins\": [\"prettier-plugin-sql-cst\"],\n  \"overrides\": [\n    {\n      \"files\": [\"*.sql\"],\n      \"options\": { \"parser\": \"sqlite\" }\n    }\n  ]\n}\n\n// Then create a SQL file (e.g., test.sql):\nSELECT a, b, c FROM tbl WHERE x > 10;\n\n// Run prettier:\n// npx prettier --write test.sql\n\n// Output:\nSELECT a, b, c\nFROM tbl\nWHERE x > 10;","lang":"javascript","description":"Shows how to install the plugin, configure it in .prettierrc.json, and format a basic SQL query.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}