explaingit

aemkei/jsfuck

8,587JavaScriptAudience · developerComplexity · 1/5Setup · easy

TLDR

A JavaScript curiosity that proves any program can be written using only six characters, an educational experiment revealing how JavaScript silently converts between types.

Mindmap

mindmap
  root((jsfuck))
    What it does
      JS encoding
      Six chars only
      Type coercion demo
    Tech Stack
      JavaScript
    How it works
      Array coercions
      String building
      Function access
    Use Cases
      Education
      Language internals
      Esoteric coding
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

Things people build with this

USE CASE 1

Convert any JavaScript snippet into JSFuck encoding to see how type coercion builds up values from nothing

USE CASE 2

Study the library source to learn how JavaScript handles automatic type conversion between numbers, strings, and arrays

USE CASE 3

Use the live demo at jsfuck.com to encode small scripts for educational experiments or puzzles

Tech stack

JavaScript

Getting it running

Difficulty · easy Time to first run · 5min

In plain English

JSFuck is an experiment that proves you can write any JavaScript program using only six characters: [, ], (, ), !, and +. The result looks nothing like normal code. A simple alert(1) turns into dozens of lines of brackets and plus signs. Despite looking like noise, it executes correctly in any standard JavaScript environment, including browsers and Node.js. The project works by exploiting how JavaScript handles type conversions. JavaScript freely converts between numbers, strings, booleans, and arrays depending on context. For example, an empty array [] treated as a number becomes zero, and treated as a string becomes an empty string. By carefully combining these coercions with the handful of allowed characters, you can build any digit, any letter, and eventually any string or function call. The README walks through each step: how to get the number 1, how to get the word undefined, how to extract individual characters from that word, and how to eventually build method names like filter or constructor that let you run arbitrary code. This is described as an esoteric and educational project. Esoteric means it is intentionally impractical, more of a curiosity or puzzle than something you would use in real software. Educational means studying it reveals real things about how JavaScript's type system works under the hood, which is why it has attracted attention from developers curious about language internals. The library includes a conversion function so you can input any JavaScript code and get the JSFuck equivalent out. A live demo is available at jsfuck.com. The README is detailed, explaining the logic behind each character and each step in building up from simple values to complete programs.

Copy-paste prompts

Prompt 1
Using JSFuck's logic, explain step by step how JavaScript builds the number 1 and the letter 'a' from only brackets, parentheses, exclamation marks, and plus signs.
Prompt 2
I want to encode a small JavaScript function using the JSFuck library. Show me how to call the conversion function and explain what the output represents.
Prompt 3
Help me understand how JSFuck constructs a function call like alert(1) purely from type coercions, walk me through each stage from empty array to executable code.
Open on GitHub → Explain another repo

← aemkei on gitmyhub — every repo by this author, as a profile.

Verify against the repo before relying on details.