{"id":12279,"library":"unescape-js","title":"Unescape JavaScript and Python Escape Sequences","description":"unescape-js is a lightweight JavaScript utility designed to convert strings containing JavaScript and Python-style escape sequences back into their literal characters. This includes standard JavaScript escapes like `\\n`, `\\t`, Unicode escapes such as `\\u00A9` for copyright, and ES2015 Unicode code point escapes like `\\u{1F604}`. It also supports Python-style Unicode character escapes (`\\UXXXXXXXX`). The current stable version is 1.1.4, though the package has not seen updates for approximately six years, indicating an abandoned or extremely low-maintenance status. A key differentiator is its robust handling of various octal escape sequence nuances, which was significantly improved in earlier versions to prevent misinterpretation of single, double, and three-digit octal codes, including those starting with `\\0` and sequences with non-octal digits.","status":"abandoned","version":"1.1.4","language":"javascript","source_language":"en","source_url":"https://github.com/iamakulov/unescape-js","tags":["javascript","unescape","escape sequences","special characters"],"install":[{"cmd":"npm install unescape-js","lang":"bash","label":"npm"},{"cmd":"yarn add unescape-js","lang":"bash","label":"yarn"},{"cmd":"pnpm add unescape-js","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"The library primarily exposes a CommonJS default export. Direct ESM import via `import ... from 'pkg'` may lead to undefined behavior or require specific bundler configurations for interoperability. TypeScript definitions confirm a CommonJS default export.","wrong":"import unescapeJs from 'unescape-js';","symbol":"unescapeJs","correct":"const unescapeJs = require('unescape-js');"}],"quickstart":{"code":"const unescapeJs = require('unescape-js');\n\n// Basic string with a newline escape\nconsole.log(unescapeJs('Hello,\\nworld!'));\n// Expected: Hello,\n//           world!\n\n// Unicode character escape\nconsole.log(unescapeJs('Copyright \\u00A9 2024'));\n// Expected: Copyright © 2024\n\n// ES2015 Unicode code point escape (emoji)\nconsole.log(unescapeJs('Smile: \\u{1F604}'));\n// Expected: Smile: 😄\n\n// Python-style Unicode escape\nconsole.log(unescapeJs('High five: \\U0001F590'));\n// Expected: High five: ✋\n\n// Complex example with various escapes\nconst escapedString = 'This is a test.\\tNew line after tab: \\n\\rAnd a carriage return.\\u{1F4A9}';\nconsole.log(unescapeJs(escapedString));\n// Expected: This is a test. New line after tab: \n//           And a carriage return.💩","lang":"javascript","description":"Demonstrates how to import and use `unescapeJs` to convert various JavaScript and Python-style escape sequences into their literal characters, including newlines, tabs, and different Unicode formats."},"warnings":[{"fix":"Upgrade to `unescape-js@1.0.8` or newer to ensure correct handling of octal escape sequences.","message":"Prior to version 1.0.8, the library improperly parsed several forms of octal escape sequences, leading to incorrect unescaping results for `\\017`, `\\5`, `\\72`, and octal sequences containing non-octal digits like `\\019`.","severity":"gotcha","affected_versions":"<1.0.8"},{"fix":"Upgrade to `unescape-js@1.1.4` or later to avoid installing superfluous `@babel` dependencies.","message":"Version 1.1.3 of the package incorrectly listed `@babel` packages as regular `dependencies` instead of `devDependencies`, leading to unnecessary package bloat upon installation.","severity":"gotcha","affected_versions":"1.1.3"},{"fix":"No direct fix; proceed with caution. Consider if the lack of ongoing maintenance poses a risk for your application, or if alternative, actively maintained libraries are available that serve similar needs.","message":"The `unescape-js` package has not been updated in approximately six years (since v1.1.4 was published). This indicates the project is likely abandoned. While it remains functional for its core purpose, users should be aware that it may not receive updates for new JavaScript features, bug fixes, or security vulnerabilities.","severity":"gotcha","affected_versions":">=1.1.4"}],"env_vars":null,"last_verified":"2026-04-19T00:00:00.000Z","next_check":"2026-07-18T00:00:00.000Z","problems":[{"fix":"Ensure your project is configured for CommonJS (e.g., omit `\"type\": \"module\"` from `package.json` and use `.js` files) or use dynamic import `import('unescape-js').then(mod => mod.default('...')` if strictly in ESM.","cause":"Attempting to use `require()` in an ECMAScript Module (ESM) context (e.g., in a file with `\"type\": \"module\"` in `package.json` or a `.mjs` file).","error":"ReferenceError: require is not defined"},{"fix":"For CommonJS, use `const unescapeJs = require('unescape-js');`. If using a bundler that transpiles CJS to ESM, `import unescapeJs from 'unescape-js';` might work, but the canonical CJS import is recommended.","cause":"Attempting to import `unescapeJs` as a named export (`import { unescapeJs } from 'unescape-js';`) when the library provides a CommonJS default export.","error":"TypeError: unescapeJs is not a function"}],"ecosystem":"npm"}