Skip to content

Latest commit

ย 

History

6 Commits

Folders and files

NameName
Last commit message
Last commit date
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿ”ฎ Obscura โ€” JavaScript Obfuscator

Protect your JavaScript source code directly in the browser. No uploads, no server, fully client-side.

๐Ÿ”— Live Demo: https://obscura-nine-peach.vercel.app/


๐Ÿ“– Table of Contents


Overview

Obscura is a fully client-side JavaScript obfuscation tool built as a single index.html file. It allows developers to obfuscate their JavaScript code directly in the browser without sending any code to a server.

The tool uses a dual-engine approach:

  • Full engine โ€” javascript-obfuscator (primary, all features)
  • Lite engine โ€” Terser (fallback, if primary CDN fails)

Features

  • โœ… Paste or upload .js, .ts, .mjs, .cjs files
  • โœ… Drag & drop file support
  • โœ… 10+ configurable obfuscation options
  • โœ… Dual-engine with automatic fallback
  • โœ… Capability guard โ€” warns before running unsupported features
  • โœ… Progress bar animation during processing
  • โœ… Copy to clipboard & download obfuscated output
  • โœ… Input/output character count + size ratio stats
  • โœ… DevTools protection (blocks right-click, F12, Ctrl+Shift+I, etc.)
  • โœ… Responsive layout (mobile-friendly)
  • โœ… Built-in Help page
  • โœ… Zero dependencies, single HTML file
  • โœ… No analytics, no cookies, no data collection

How It Works

  1. User pastes or uploads JavaScript code into the Input panel.
  2. The tool reads the selected obfuscation options.
  3. On clicking OBFUSCATE โ†’ (or pressing Ctrl+Enter):
    • The engine is detected (full or lite).
    • A capability guard checks if any active options are unsupported by the current engine โ€” if so, a modal warns the user.
    • The obfuscation runs entirely in the browser.
  4. The obfuscated code appears in the Output panel.
  5. User can Copy or Download the result as .obfuscated.js.

Getting Started

Since Obscura is a single HTML file, no build step or installation is required.

# Clone the repository
git clone https://github.com/andiasriefail2004/Obscuraโ€”JavaScript-Obfuscator.git

# Open directly in browser
open index.html

Or just visit the live demo: https://obscura-nine-peach.vercel.app/


Obfuscation Options

Option Engine Description
Rename Variables Full + Lite Replaces all variable, function, and parameter names with short unreadable identifiers.
String Array Full only Extracts all string literals into a hidden encoded array and replaces them with lookup calls.
Dead Code Injection Full only Injects random fake code blocks that never execute, making the real flow harder to follow. โš  Can increase output size by up to 200%.
Control Flow Flattening Full only Restructures every function into a flat dispatcher loop, hiding the original logical order. โš  Can slow runtime by up to 1.5ร—.
Self Defending Full only Makes the obfuscated code break if it is reformatted or beautified.
Debug Protection Full only Continuously forces the debugger to activate, making DevTools nearly unusable on the output. โš  May freeze the browser tab.
Drop Console Full + Lite Replaces all console.* calls with empty functions, silencing runtime logging.
Drop Debugger Full + Lite Removes all debugger; statements from the output.
Numbers to Expressions Full only Converts numeric literals into complex arithmetic expressions that evaluate to the same value.
Split Strings Full only Splits string literals into smaller chunks joined at runtime, making strings harder to search.

Identifier Style (Full only)

Value Description
hexadecimal Identifiers like _0x1a2b3c
mangled Short identifiers like a, b, c
mangled-shuffled Short identifiers in shuffled order

Target Environments

Target Description
Browser Standard web page. Default โ€” suitable for most browser JS.
Browser (no eval) Same as Browser but avoids eval(). Use with strict CSP policies.
Node.js Server-side Node.js. Disables browser-specific protections relying on window/document.
Service Worker Service Worker context. Uses self global instead of window.
Userscript Tampermonkey / Greasemonkey sandbox. Defenses adjusted for userscript environment.
Bytenode Prepares output for compilation into V8 cached bytecode (.jsc) via bytenode.

Engine System

Obscura loads the primary engine (javascript-obfuscator) asynchronously from CDN on startup. If the CDN fails to load, it falls back to Terser (lite engine).

Startup
  โ””โ”€โ”€ Load javascript-obfuscator from jsDelivr CDN
        โ”œโ”€โ”€ Success โ†’ window._obfEngine = 'full'
        โ””โ”€โ”€ Fail    โ†’ Load source-map.js โ†’ Load terser bundle.min.js
              โ”œโ”€โ”€ Success โ†’ window._obfEngine = 'lite'
              โ””โ”€โ”€ Fail    โ†’ window._obfEngine = null (shows error)

When the engine is lite, features exclusive to full (String Array, Dead Code Injection, etc.) are blocked. If the user has those options enabled, a capability modal appears before processing, listing which features will be skipped and which will still run.


Third-Party Libraries / APIs

Obscura loads all libraries from jsDelivr CDN โ€” no custom backend API is used.

Library Role CDN URL
javascript-obfuscator Primary obfuscation engine (full engine) https://cdn.jsdelivr.net/npm/javascript-obfuscator/dist/index.browser.js
source-map Dependency required by Terser (loaded only on fallback) https://cdn.jsdelivr.net/npm/source-map@latest/dist/source-map.js
Terser Fallback minification/obfuscation engine (lite engine) https://cdn.jsdelivr.net/npm/terser@latest/dist/bundle.min.js
Google Fonts Loads JetBrains Mono and Inter typefaces for the UI https://fonts.googleapis.com / https://fonts.gstatic.com

No server-side API calls are made with user code. All processing happens in the browser.


Security Headers

Both deployment configurations apply the same four security headers to all routes.

Header Reference

Header Value Purpose
Content-Security-Policy (see below) Controls which resources the browser is allowed to load
X-Content-Type-Options nosniff Prevents MIME type sniffing
X-Frame-Options DENY Blocks the page from being embedded in iframes
Referrer-Policy strict-origin-when-cross-origin Limits referrer info sent to other origins

Content-Security-Policy Breakdown

default-src 'self'

By default, only same-origin resources are allowed.

script-src 'self' 'unsafe-inline' 'unsafe-eval'
  https://cdn.jsdelivr.net/npm/javascript-obfuscator/dist/index.browser.js
  https://cdn.jsdelivr.net/npm/source-map@latest/dist/source-map.js
  https://cdn.jsdelivr.net/npm/terser@latest/dist/bundle.min.js

unsafe-inline is required for the inline <script> blocks. unsafe-eval is required because javascript-obfuscator uses eval() internally. Only the three specific jsDelivr CDN scripts are whitelisted.

style-src  'self' 'unsafe-inline' https://fonts.googleapis.com
font-src   'self' https://fonts.gstatic.com
connect-src 'self'
img-src    'self' data:
object-src 'none'
base-uri   'self'
frame-ancestors 'none'

data: is allowed under img-src to support the inline SVG favicon. frame-ancestors 'none' reinforces the X-Frame-Options: DENY directive at the CSP level.


Cloudflare Pages (_headers)

Place _headers in the root of your repository (next to index.html). Cloudflare Pages picks it up automatically.

/*
  Content-Security-Policy: default-src 'self'; script-src 'self' 'unsafe-inline' 'unsafe-eval' https://cdn.jsdelivr.net/npm/javascript-obfuscator/dist/index.browser.js https://cdn.jsdelivr.net/npm/source-map@latest/dist/source-map.js https://cdn.jsdelivr.net/npm/terser@latest/dist/bundle.min.js; style-src 'self' 'unsafe-inline' https://fonts.googleapis.com; font-src 'self' https://fonts.gstatic.com; connect-src 'self'; img-src 'self' data:; object-src 'none'; base-uri 'self'; frame-ancestors 'none'
  X-Content-Type-Options: nosniff
  X-Frame-Options: DENY
  Referrer-Policy: strict-origin-when-cross-origin

The /* pattern applies the headers to every page and asset.


Vercel (vercel.json)

Place vercel.json in the root of your repository. Vercel reads it on each deployment.

{
  "headers": [
    {
      "source": "/(.*)",
      "headers": [
        {
          "key": "Content-Security-Policy",
          "value": "default-src 'self'; script-src 'self' 'unsafe-inline' 'unsafe-eval' https://cdn.jsdelivr.net/npm/javascript-obfuscator/dist/index.browser.js https://cdn.jsdelivr.net/npm/source-map@latest/dist/source-map.js https://cdn.jsdelivr.net/npm/terser@latest/dist/bundle.min.js; style-src 'self' 'unsafe-inline' https://fonts.googleapis.com; font-src 'self' https://fonts.gstatic.com; connect-src 'self'; img-src 'self' data:; object-src 'none'; base-uri 'self'; frame-ancestors 'none'"
        },
        { "key": "X-Content-Type-Options", "value": "nosniff" },
        { "key": "X-Frame-Options", "value": "DENY" },
        { "key": "Referrer-Policy", "value": "strict-origin-when-cross-origin" }
      ]
    }
  ]
}

The source: "/(.*)" regex matches every route.


Deployment

Vercel

  1. Push index.html and vercel.json to a GitHub/GitLab repository.
  2. Import the repository at vercel.com.
  3. No build command or output directory needed โ€” Vercel serves index.html directly.
  4. Security headers are applied automatically via vercel.json.

Cloudflare Pages

  1. Push index.html and _headers to a GitHub/GitLab repository.
  2. Create a new Pages project at pages.cloudflare.com.
  3. No build command needed โ€” set the output directory to / (root).
  4. Security headers are applied automatically via _headers.

Static / Self-hosted

Just serve index.html from any static file server (Nginx, Apache, GitHub Pages, etc.). Configure the security headers manually in the server config if needed.


Privacy

  • Your code is never uploaded or stored. All obfuscation runs entirely inside your browser.
  • This tool makes no server requests with your code. The only network activity is loading the obfuscator libraries from jsDelivr CDN on first use.
  • No analytics, cookies, or personally identifiable information are collected.
  • Third-party libraries (javascript-obfuscator and Terser) are open-source and can be audited independently.

File Structure

.
โ”œโ”€โ”€ index.html      # The entire application โ€” UI, styles, and logic in one file
โ”œโ”€โ”€ _headers        # Security headers for Cloudflare Pages deployment
โ”œโ”€โ”€ vercel.json     # Security headers + config for Vercel deployment
โ””โ”€โ”€ README.md       # This file

License

MIT โ€” free to use, modify, and deploy.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages