Rail Fence Cipher

Encrypt and decrypt the zigzag transposition cipher

Free rail fence cipher tool — encrypt and decrypt messages with the classic zigzag transposition cipher, rails 2 to 10, instantly in your browser.

How to use Rail Fence Cipher

  1. Type or paste your message.
  2. Set the number of rails (2 to 10, default 3).
  3. Choose Encrypt or Decrypt and press the button.
  4. Copy the result with one click.

Features

  • Encrypt and decrypt with rails 2 to 10
  • Default 3 rails — the classic textbook setup
  • Instant, in-browser — nothing uploaded
  • Copy result to clipboard

Frequently asked questions

What is the Rail Fence cipher?

A transposition cipher: the plaintext is written in a zigzag across a number of rails and read off row by row. With 3 rails, HELLO becomes HOELL — H and O on the top rail, E and L in the middle, L on the bottom. No letters change, only their order.

How do I encrypt WEAREDISCOVEREDFLEEATONCE?

With 3 rails it becomes WECRLTEERDSOEEFEAOCAIVDEN — the textbook example, and this tool produces exactly that. Rail 0 holds W E C R L T E, rail 1 holds E R D S O E E F E A O C, and rail 2 holds A I V D E N.

How do I decode a Rail Fence message?

Enter the ciphertext, set the same number of rails used to encrypt it, and choose Decrypt. WECRLTEERDSOEEFEAOCAIVDEN on 3 rails decodes back to WEAREDISCOVEREDFLEEATONCE, and CBKOERAIGDEN decodes to CODEBREAKING. The tool marks the zigzag path first, fills the rails row by row, then reads along the path.

What rail count should I use?

The slider runs from 2 to 10 rails and starts at 3 — the classic textbook setup. 2 rails is the simplest fence: HELLO becomes HLOEL. More rails scramble the text more, but every rail count is easy to try, which is why the cipher is not secure.

Does the tool guess the rail count for me?

No — you must know the number of rails used. There is no brute-force or auto-detect mode: enter the ciphertext, set the rails, and decrypt. If you do not know the count, try 2 through 10 by hand — with only nine possibilities it takes seconds.

Are spaces and punctuation kept?

Yes. Every character, including spaces, is zigzagged like any other letter, and decrypting restores them exactly. A short message can also come back unchanged: if the rail count is equal to or larger than the message length, the tool returns the text as-is — HI on 3 rails stays HI.

Login to use this free online tool. Create a free account to get started.

Featured on Twelve Tools Hunt for Tools Featured on LaunchBuff Launch Llama Tools Launch your MCP Top Web Development Companies in the US - OnToplist.com Designer Listings Listed on SeeWhatNewAI Featured on SubmitMySaas Featured on AI Agents Directory Product Wing SaaS Wheel Featured on Stremit Featured on Thank John We Are Founders SubmitMySaas ShinyLaunch SaaS Tools Dir Featured on SaasHunt Product List Dir Featured on ShowMeBestAI Listed on Best-AI.org Featured on SaaSCity Listed on LaunchPact CodexFuse Solution on goodSaaS Featured on IndieLaunch Featured on BestAIApps AI X Collection Featured on SemiLaunch Listed on AlterBase We Like Tools codexfuse.dev LaunchClash Featured on Next Launch