Skip to content

↑↓ navigate ↵ open Esc close Search runs locally

Bacon Cipher Encoder & Decoder (Hide Messages in Text)

Encode letters as groups of five A/B symbols, or hide a secret message in the capital letters of an ordinary sentence. Supports the original 24-letter and the modern 26-letter alphabet.

  • Runs in your browser
  • Nothing is uploaded
  • Free, no sign-up
0 chars
Bacon
Runs in your browser. Nothing is uploaded. Tip: choose "Hidden in text" to hide a message in capital letters

How to use the Bacon cipher tool#

  1. Choose Encode or Decode and pick the Alphabet: 26 letters, or Bacon's original 24 (I = J and U = V).
  2. Choose the Output: A/B groups, 0/1 groups, or Hidden in text, which writes the message as lowercase and capital letters of your Cover text.
  3. Type the message. In Hidden in text mode, the cover sentence is repeated if it is too short.
  4. To decode, paste A/B groups, 0/1 groups or a hidden-text sentence: the format is detected automatically.

Examples#

Encode a word

Input
Hello
Output
AABBB AABAA ABABB ABABB ABBBA

H is letter 7 (00111 in binary), so it becomes AABBB.

Decode A/B groups

Input
AABBB AABAA ABABB ABABB ABBBA
Output
HELLO

Spaces between groups are optional when decoding.

Hide a message in a sentence

Input
HI
Output
thEBA cOnci pher hides secrets

Lowercase letters mean A and capitals mean B: thEBA cOnci reads AABBB ABAAA, which is H I.

Decode a hidden message

Input
thEBA cOnci pher hides secrets
Output
HI

Trailing all-lowercase groups after the message are ignored.

What is the Bacon cipher?#

The Bacon cipher (or Baconian cipher) writes every letter as a group of five symbols that are each either A or B. It was devised by Francis Bacon around 1605. Its real strength is not the code itself but where it can hide: the A and B can be any two things that look alike, such as two fonts, lowercase and capital letters, or bold and normal text. That makes it an early example of steganography, hiding the very existence of a message.

The Bacon alphabet#

Each letter's position (starting at 0) is written in binary with five digits, with A for 0 and B for 1. In the modern 26-letter version:

LetterCodeLetterCodeLetterCode
AAAAAAJABAABSBAABA
BAAAABKABABATBAABB
CAAABALABABBUBABAA
DAAABBMABBAAVBABAB
EAABAANABBABWBABBA
FAABABOABBBAXBABBB
GAABBAPABBBBYBBAAA
HAABBBQBAAAAZBBAAB
IABAAARBAAAB

Bacon's original alphabet had only 24 letters: I and J shared a code, and so did U and V. Choose 24 letters to match old texts and many puzzle books.

Hiding a message in ordinary text#

Write any sentence, then use its letters as carriers: a lowercase letter means A and a capital letter means B. Each group of five letters carries one hidden letter. With the cover text "the bacon cipher hides secrets", the message HI (AABBB ABAAA) becomes thEBA cOnci pher hides secrets. Spaces and punctuation are ignored when reading, and the cover needs five letters for every letter of the secret.

Bacon himself proposed using two slightly different typefaces, so the hidden message would be invisible to anyone not looking for it.

Hidden is not the same as secure. Once someone suspects a Bacon cipher, it is easy to read. It is perfect for puzzles and games.

Bacon cipher in code#

javascript
const encode = (text) =>  [...text.toUpperCase().replace(/[^A-Z]/g, '')]    .map((c) => (c.charCodeAt(0) - 65).toString(2).padStart(5, '0').replace(/0/g, 'A').replace(/1/g, 'B'))    .join(' '); const decode = (code) =>  code.replace(/[^AB]/gi, '').toUpperCase().match(/.{5}/g)    .map((g) => String.fromCharCode(65 + parseInt(g.replace(/A/g, '0').replace(/B/g, '1'), 2)))    .join(''); encode('Hello'); // "AABBB AABAA ABABB ABABB ABBBA"

Common errors and fixes#

  • The decoded text is almost right but some letters are off by one

    The message uses the other alphabet. Switch between 26 letters and 24 letters (where I = J and U = V).

  • A hidden-text message decodes with extra letters

    The cover text has stray capitals, such as at the start of a sentence or in names. Hidden text must only use capitals for B. Write the cover in lowercase before encoding.

  • Some letters decode as ?

    A group of five is not a valid code (for example BBBBB in the 26-letter alphabet), or a symbol is missing and the groups are misaligned.

Frequently asked questions#

How does the Bacon cipher work?

Each letter becomes five symbols, each A or B, like a 5-bit binary number. H, for example, is AABBB. The A and B can then be hidden as two different styles of letters.

What is the difference between the 24 and 26-letter versions?

Bacon's original version merged I with J and U with V, giving 24 letters. The modern version gives every letter its own code.

How do I hide a message with the Bacon cipher?

Choose Encode and set Output to Hidden in text, then type your secret and a cover sentence. Lowercase letters stand for A and capitals for B.

Is my text uploaded?

No. Everything runs in your browser.

Your next tool is one search away.

Free, private developer tools that run in your browser. No signup, nothing uploaded, no waiting.

Browse all tools

Tip: press Ctrl D to bookmark dev247.