Rail Fence Cipher
Encode and decode the rail-fence zig-zag transposition cipher.
- Runs locally in your browser
- No upload required
Try it
Supported formats
Privacy
Runs entirely in your browser. Your input is never uploaded, stored, or sent to a third party.
Rail fence encode with 3 rails.
How it works
- Wrote the text along a zig-zag over the requested number of rails.
- Read each rail in turn to produce the ciphertext (or inverted the step to decode).
- Spaces and punctuation are treated as ordinary characters and transposed.
Methodology
- Read the input text one character at a time.
- Apply the cipher or encoding transformation for the chosen direction.
- Return the transformed text with a short summary.
Usage
- Paste or type the text to convert.
- Choose Encode or Decode.
- Read the converted text and copy it.
Examples
These are examples, not current values: they use fixed inputs, while the interactive tool computes live results in your browser.
Encode a sample
{
"text": "HELLO WORLD",
"direction": "encode",
"rails": 3
}Decode a sample
{
"text": "HOELL",
"direction": "decode",
"rails": 3
}Limitations
How the Rail Fence Cipher works
Encode and decode the rail-fence zig-zag transposition cipher. The transformation is a single deterministic pass, so the same input always produces the same output.
Frequently asked questions
- Is this cipher secure?
- No. Classical substitution and transposition ciphers are educational and are not suitable for protecting real secrets.
- Does everything round-trip?
- Reversible ciphers round-trip for alphabetic input; encodings that normalise case or drop characters document that in their notes.
Sources
- ECMA-262: ECMAScript Language Specification — Ecma International
- MDN Web Docs — JavaScript String and code point reference — MDN
Send feedback
Tell us if this tool helped, report a problem, or suggest a tool. Only the message you type is sent — never the input you used in the tool.
Was this tool useful?
Prefer to write to us directly? See the contact page.