Skip to main content

Rail Fence Cipher

Write text in a zig-zag over 2 to 20 rails to encode it, see the grid, and try every rail count to decode. Free and private.

More options

This is not secure encryption: anyone can break it. Use AES encryption for real secrets.

Shortcuts: Ctrl+Enter run · Ctrl+Shift+C copy result · / search (use ⌘ on Mac)

Free Rail Fence Cipher

The text is written diagonally down and up across rails, then read row by row. It rearranges letters but does not change them. It gives developers a quick browser-based way to solve a focused rail fence cipher task before moving the result into a project.

How to use Rail Fence Cipher

Set the number of rails. The grid shows how the letters were laid out. For a message with an unknown number of rails, Decode lists 2 to 10 rails.

Common mistakes

  • Using more rails than letters: the text must be longer than the rail count.
  • Forgetting spaces count as characters: they are moved like letters.

Frequently asked questions

How does the rail fence work?
Write the letters going down the rails and back up, like a zig-zag. Then read each rail from left to right and join them.
What does the offset do?
It starts the zig-zag part-way along, which changes the result. Both sides need the same offset.
Is it secure?
No. Only the order of letters changes, and there are few rail counts to try.
Is anything uploaded?
No. The calculation runs in your browser and nothing you enter is sent to a server.
How do I use this rail fence cipher tool?
Use the interactive controls above; processing stays in your browser and the result is intended as a practical starting point for development work.

More Security & Auth

View all Security & Auth tools →