{"id":11150,"library":"js-beautify","title":"JS Beautify","description":"JS Beautify is a robust JavaScript library and command-line tool designed for reformatting and re-indenting JavaScript, CSS, and HTML code. It can also unpack and partially deobfuscate scripts processed by common tools like Dean Edward’s packer or `javascript-obfuscator`. The current stable version is 1.15.4, with recent releases addressing compatibility and hotfixes, such as the `polyfill.io` removal and `glob` dependency adjustments for Node.js 18.x. The project distinguishes itself by offering multi-language code formatting and basic de-obfuscation capabilities, which are beyond the scope of many single-purpose formatters. However, the project explicitly states a critical need for new contributors, indicating that existing owners have limited time, which suggests a potentially slower development pace and a maintenance-focused trajectory despite ongoing minor updates.","status":"maintenance","version":"1.15.4","language":"javascript","source_language":"en","source_url":"git://github.com/beautifier/js-beautify","tags":["javascript","beautify","beautifier","code-quality"],"install":[{"cmd":"npm install js-beautify","lang":"bash","label":"npm"},{"cmd":"yarn add js-beautify","lang":"bash","label":"yarn"},{"cmd":"pnpm add js-beautify","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"The primary JavaScript beautifier function is a named export. For CommonJS, use `require('js-beautify').js_beautify`.","wrong":"import beautify from 'js-beautify';\nconst beautify = require('js-beautify');","symbol":"js_beautify","correct":"import { js_beautify } from 'js-beautify';"},{"note":"For CSS, `css_beautify` is a named export. Older CommonJS examples might show `require('js-beautify').css` but the `_beautify` suffix is standard.","wrong":"const cssBeautify = require('js-beautify').css;","symbol":"css_beautify","correct":"import { css_beautify } from 'js-beautify';"},{"note":"Similar to CSS, `html_beautify` is the named export. Older CommonJS usage might use `require('js-beautify').html`.","wrong":"const htmlBeautify = require('js-beautify').html;","symbol":"html_beautify","correct":"import { html_beautify } from 'js-beautify';"}],"quickstart":{"code":"import { js_beautify, css_beautify, html_beautify } from 'js-beautify';\n\nconst uglyJavaScript = `\nfunction  myFunction ( a , b ){return a + b  ;}\n`;\n\nconst uglyCSS = `\nbody{ margin:0;padding:0;}\n`;\n\nconst uglyHTML = `\n<div><span>Hello</span><p>World</p></div>\n`;\n\nconst jsOptions = { indent_size: 2, space_in_empty_paren: true, keep_array_indentation: false };\nconst cssOptions = { indent_size: 4 };\nconst htmlOptions = { indent_size: 2, wrap_line_length: 80 };\n\nconst beautifulJavaScript = js_beautify(uglyJavaScript, jsOptions);\nconst beautifulCSS = css_beautify(uglyCSS, cssOptions);\nconst beautifulHTML = html_beautify(uglyHTML, htmlOptions);\n\nconsole.log('--- Beautiful JavaScript ---\\n', beautifulJavaScript);\nconsole.log('--- Beautiful CSS ---\\n', beautifulCSS);\nconsole.log('--- Beautiful HTML ---\\n', beautifulHTML);\n\n/* Example Output:\n-- Beautiful JavaScript ---\n function myFunction (a, b) {\n  return a + b;\n }\n-- Beautiful CSS ---\n body {\n    margin: 0;\n    padding: 0;\n }\n-- Beautiful HTML ---\n <div>\n  <span>Hello</span>\n  <p>World</p>\n </div>\n*/","lang":"javascript","description":"This quickstart demonstrates how to use `js-beautify` to format JavaScript, CSS, and HTML strings with custom options."},"warnings":[{"fix":"Consider contributing to the project if you rely on it heavily, or be aware of potential slower updates and community-driven support.","message":"The `js-beautify` project is actively seeking new contributors due to limited time from existing maintainers. This could impact future development, bug fixes, and feature additions, suggesting a reliance on community contributions for its long-term vitality.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Update to `js-beautify` v1.15.1 or newer to avoid `polyfill.io` dependency. Ensure your environment provides necessary polyfills if any were implicitly consumed via `polyfill.io` in older versions.","message":"Version 1.15.1 included a hotfix to remove `polyfill.io` usage. If your projects were relying on older versions of `js-beautify` that implicitly used `polyfill.io`, this change might have impacted script loading or functionality if `polyfill.io` became unavailable or changed its behavior.","severity":"breaking","affected_versions":"<1.15.1"},{"fix":"Upgrade to `js-beautify` v1.15.3 or later to ensure compatibility with Node.js 18.x, as the `glob` dependency has been adjusted for broader support.","message":"Version 1.15.3 downgraded the `glob` dependency to v10.x to ensure compatibility with Node.js 18.x. Users on specific Node.js or `glob` versions might have encountered compatibility issues with earlier `js-beautify` releases that used newer `glob` versions.","severity":"gotcha","affected_versions":">=1.15.0 <1.15.3"}],"env_vars":null,"search_vec":"'1.15.4':53 '18':72 'address':57 'adjust':69 'also':29 'basic':86 'beautifi':2,4,138,139 'beyond':93 'capabl':90 'code':26,83,141 'code-qu':140 'command':12 'command-lin':11 'common':37 'compat':58 'contributor':112 'critic':108 'css':23 'current':49 'de':88 'de-obfusc':87 'dean':40 'deobfusc':33 'depend':68 'design':15 'despit':133 'develop':125 'distinguish':76 'edward':41 'exist':115 'explicit':105 'focus':131 'format':84 'formatt':101 'glob':67 'hotfix':60 'howev':102 'html':25 'indent':21 'indic':113 'javascript':8,22,46,137 'javascript-obfusc':45 'js':1,3 'languag':82 'librari':9 'like':39 'limit':118 'line':13 'mainten':130 'maintenance-focus':129 'mani':97 'minor':135 'multi':81 'multi-languag':80 'need':109 'new':111 'node.js':71 'obfusc':47,89 'offer':79 'ongo':134 'owner':116 'pace':126 'packer':43 'partial':32 'polyfill.io':64 'potenti':123 'process':35 'project':75,104 'purpos':100 'qualiti':142 're':20 're-ind':19 'recent':55 'reformat':17 'releas':56 'remov':65 'robust':7 'scope':95 'script':34 'singl':99 'single-purpos':98 'slower':124 'stabl':50 'state':106 'suggest':121 'time':119 'tool':14,38 'trajectori':132 'unpack':30 'updat':136 'version':51 'x':73","created_at":"2026-04-19T13:36:29.781277+00:00","updated_at":"2026-04-19T13:36:29.781277+00:00","problems":[{"fix":"Use named imports: `import { js_beautify } from 'js-beautify';` for ESM, or `const { js_beautify } = require('js-beautify');` for CommonJS. Alternatively, for CommonJS, `const js_beautify = require('js-beautify').js_beautify;`.","cause":"Attempting to import `beautify` as a default export or using `require('js-beautify')` directly without specifying `js_beautify` when the library primarily uses named exports.","error":"TypeError: js_beautify is not a function"},{"fix":"Either convert your project or file to an ESM module by adding `\"type\": \"module\"` to your `package.json` or changing file extension to `.mjs`, or use CommonJS `require()` syntax: `const { js_beautify } = require('js-beautify');`.","cause":"Using `import` syntax in a Node.js CommonJS module (e.g., in a `.js` file without `\"type\": \"module\"` in `package.json`).","error":"SyntaxError: Cannot use import statement outside a module"},{"fix":"Ensure you are using the correct beautifier function for the specific language: `html_beautify` for HTML and `css_beautify` for CSS. Pass relevant options for the chosen beautifier, as their options sets may differ.","cause":"Attempting to use `js_beautify` function for HTML code, or not providing appropriate HTML-specific options.","error":"js-beautify isn't correctly formatting simple html"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":"js-beautify","cli_version":null,"type":"library","homepage":"https://beautifier.io","github":"https://github.com/beautifier/js-beautify","docs":null,"changelog":null,"pypi":null,"npm":"https://www.npmjs.com/package/js-beautify","openapi_spec":null,"status_page":null,"smithery":null,"categories":["serialization"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-17","next_check":"2026-07-18","install_tag":null}}