Instant SQL Formatter
format your query with options
Reference : https://www.dpriver.com/pp/sqlformat.htm
How to Use
const formatter = require("instant-sql-formatter")
function basicFunction() {
let vQuery = "select * from dual"
formatter.format(vQuery).then(res=>{
console.log(res)
})
}
async function asyncFunction() {
let vQuery = "select * from dual"
let vConvQuery = await formatter.format(vQuery)
console.log(vConvQuery)
}
select * from dual
SELECT *
FROM DUAL
Variable Options
let options = {
dbvendor : "oracle",
outputfmt : "SQL",
keywordcs : "Uppercase",
tablenamecs : "Uppercase",
columnnamecs : "Uppercase",
functioncs : "Uppercase",
datatypecs : "Uppercase",
variablecs : "Uppercase",
aliascs : "Uppercase",
quotedidentifiercs : "Uppercase",
identifiercs : "Uppercase",
lnbrwithcomma : "beforewithspace",
liststyle : "stack",
salign : "sright",
quotechar : "\"",
maxlenincm : "80"
} -- default setting
Sample(TEXT)
let vQuery = "select * from dual"
let vConvQuery = await formatter.format(vQuery, { dbvendor:"oracle", lnbrwithcomma:"after", salign:"sright"} )
select * from dual
SELECT *
FROM DUAL
Sample(HTML Tag Options)
let vQuery = "select * from dual"
let vConvQuery = await formatter.format(vQuery, { outputfmt:"htmlkeeplayout"} )
select * from dual
<div><span style="font-family: Courier New; font-size: 10pt;">
<span style="color: blue; ">SELECT</span> <span style="color: silver; ">*</span>
<br/> <span style="color: blue; ">FROM</span> <span style="color: maroon; ">DUAL</span>
</span></div>
TIP! Easily create options
- Visit the Website(https://www.dpriver.com/pp/sqlformat.htm) and select options what you want
- Analyze transactions using developer tools.
- Edit appropriately.