User Rating 0.0
Total Usage 0 times
Characters: 0
Effective: 0
Is this tool helpful?

Your feedback helps us improve.

About

Circular left rotation shifts every character (or word) in a string by n positions toward the beginning. Characters that fall off the left edge wrap around to the right end. The operation is equivalent to taking the substring from index n mod L and concatenating the prefix before it. A rotation of n = 0 or n = L returns the original string unchanged. Incorrect rotation in cryptographic ciphers, data serialization, or circular buffer implementations causes silent data corruption that propagates downstream.

This tool computes the rotation in O(L) time using native string slicing. It supports both character-level and word-level modes. Note: word-level rotation treats consecutive whitespace as a single delimiter and discards extra spaces. Pro tip: rotating by L n positions to the left is identical to rotating n positions to the right.

text rotation circular shift left rotate string text manipulation string rotation

Formulas

The circular left rotation of a string S of length L by n positions is defined as:

R = S[n mod LL 1] + S[0n mod L 1]

The effective rotation index k is computed as:

k = n mod L

Where R = resulting rotated string, S = original input string, L = length of string (character count or word count depending on mode), n = number of positions to rotate left, k = effective rotation after modulo reduction. When k = 0, the output equals the input. The operation forms a cyclic group of order L under composition.

Reference Data

Original StringRotation (n)ModeResult
ABCDEF0CharacterABCDEF
ABCDEF1CharacterBCDEFA
ABCDEF2CharacterCDEFAB
ABCDEF3CharacterDEFABC
ABCDEF6CharacterABCDEF
ABCDEF8CharacterCDEFAB
Hello World3Characterlo WorldHel
one two three four1Wordtwo three four one
one two three four2Wordthree four one two
one two three four4Wordone two three four
A5CharacterA
AB1CharacterBA
rotate me7Charactermerotate
alpha beta gamma3Wordalpha beta gamma
a b c d e3Wordd e a b c

Frequently Asked Questions

The tool computes the effective rotation as n mod L. Rotating a 6-character string by 8 positions is equivalent to rotating by 2 positions because 8 mod 6 = 2. This matches the mathematical definition of cyclic groups.
Word-level mode splits the input on whitespace boundaries, filters out empty tokens, and joins the rotated words with a single space. Consequently, multiple consecutive spaces collapse to one, and leading or trailing whitespace is trimmed in the output. This is intentional to produce clean, normalized results.
Yes. A right rotation of n positions is identical to a left rotation of L n positions, where L is the length. For example, right-rotating "ABCDEF" by 2 equals left-rotating by 4, both yielding "EFABCD".
This tool operates on JavaScript string indices, which use UTF-16 code units. Single-codepoint emoji and standard Unicode characters rotate correctly. However, multi-codepoint emoji (e.g., family emoji composed of ZWJ sequences) may split across the rotation boundary. For such cases, word-level mode is safer if emoji are space-delimited.
The algorithm runs in O(L) time and space, where L is the string length. It uses two slice operations and one concatenation. No intermediate arrays or character-by-character loops are needed. This is optimal since the output itself requires O(L) space.