Text · Made a little simpler

Rail Fence Cipher

Reorder text in a rail fence zigzag without deleting spaces or punctuation. Use the classical plain representation or a JSON grapheme array that keeps Unicode boundaries explicit.

Free to useNo account neededProcessed on your device
Your workspaceProcessed on your device

Add this tool to your website

Paste this code into your page to add the tool and a visible ToolMellow credit link.

HTML embed code
Preview embed

Rail Fence Cipher: how to use it

  1. Paste text and enter a rail count. Choose Plain text for a classical ASCII example or JSON grapheme array to preserve boundaries.
  2. Encode down and up from the top rail. The output reads each rail in order. Save the rail count and ciphertext format alongside the result.
  3. Select Use result as input to switch to Decode. Check that the same settings restore the original text.

Limits and notes

Supports 2–128 rails and up to 16,000 UTF-16 code units of text. JSON decode input may use up to 160,000 code units, including escapes and structure. Uses browser Unicode grapheme segmentation when reading plain text. Plain output is blocked when its grapheme boundaries change.

How your privacy works →

Rail Fence Cipher: common questions

Do spaces and punctuation occupy rails?

Yes. The tool moves them as grapheme units, along with the other text. Remove any grouping spaces added for display in a textbook ciphertext before decoding that particular example.

Why do some emoji inputs need a JSON array?

New neighbors can change how Unicode groups characters. For example, two separate regional indicators can form a flag when placed together. The JSON array records each original unit independently.

Does the decoder know the rail count?

Enter the original count and choose the matching ciphertext format. The exported text or array contains the reordered units, and several rail counts can produce different valid-looking results.

Guides