Rail fence cipher decoder

Solve rail fence puzzles when you know the rail count, or try different counts until readable text appears. It is a puzzle cipher, not protection.

Loading the tool…

Processing and privacy: The result is calculated inside your browser and your data is not sent to any server.

How to use it

  1. Enter encoded text and rails.
  2. The result appears straight away and updates as you edit.
  3. Copy the result, or copy a link that keeps the same values to share it.

How it is calculated

The rail of every position is found with the same zigzag rule, the text is cut into rails by those counts, and then read back in zigzag order.

Example

Inputs: Rails = 3. Result: Decoded text: WEAREDISCOVEREDRUNATONCE; Characters: 24.

WECRUOERDSOEERNTNEAIVDAC
WEAREDISCOVEREDRUNATONCE

Limits and caveats

  • This is a puzzle and teaching cipher that is easy to break, so never use it to protect passwords or sensitive data.
  • The text must be complete with the same spacing it was encoded with, or positions shift.

Questions about this tool

I do not know the rail count. What now?

Try 2, then 3, then 4 and so on. The count is usually small and the right text shows up quickly.

Can it decode text with spaces?

Yes, as long as the spaces were part of the text when it was encoded.

Does it support a starting offset?

No. It always starts on the first rail, which is the usual form of the cipher.