What to do next
- Paste the text from before the changes into "Original text" and the text from after the changes into "New text". You can also drop a text file onto either box.
- Look at the coloured parts. A green background with an underline is added text; red text struck through is removed text.
- For long texts, leave "Fold unchanged lines" on. Only the changes and the two lines around them are shown. Press "Next change" to step through the changes from the top.
- To tell someone what you changed, press "Copy diff". Each line starts with "+" or "-", so you can paste it straight into an email or chat.
What a diff is
A diff compares two texts and picks out what was added and what was removed. It helps whenever looking for "what changed" by eye means missing something: edits to a manuscript, revisions to a contract or terms, changes to a settings file.
This tool first compares the texts line by line, then compares the changed lines character by character. So if you change one word in a long paragraph, only that word is coloured.
The two views
| View | What you see | Best for |
|---|---|---|
| Overlaid | Removed and added text next to each other within one text. Lines with a thick bar on the left are the changed lines | Texts with long paragraphs, such as emails, manuscripts and articles |
| Side by side | The original text on the left and the new text on the right, with the lines lined up | Things with short lines, such as lists, tables, settings files and code |
The numbers on the left are line numbers. The overlaid view shows the line numbers in the new text; the side-by-side view shows the numbers in each text.
How the texts are compared
The comparison uses the method Eugene W. Myers published in 1986. It looks for the steps that turn the original text into the new text with the fewest additions and removals. git, which records changes to programs, also uses this method by default.
Character-level results can be hard to read as they are, so this tool makes two adjustments to make them easier to read.
- Small fragments are merged: when a single matching character happens to survive, a change gets chopped into pieces. Unchanged runs of three characters or fewer between changes are merged into the changes around them.
- Numbers and words are replaced as a whole: if you correct "18" to "16" and only the 8 is struck through, it's easy to misread as "186". When only part of a run of digits or letters changes, it's shown as "18" removed and "16" added. Numbers with separators, such as "1,000" or "1.5", are treated as one run as well.
Differences you can ignore
- Ignore differences in spaces: compares the texts as if spaces, tabs and full-width spaces weren't there. Lines that differ only in indentation or trailing spaces count as the same.
- Ignore case: treats "Web" and "WEB" as the same.
- Ignore full-width and half-width differences: treats ABC and ABC, and カタカナ and カタカナ, as the same.
Differences in line break codes (CR+LF or LF) don't show up in the diff, because browser text boxes turn the line breaks in pasted text into LF.
How characters are counted
Different tools give different answers to "how many characters", because they count different things.
| Character | As seen | Inside programs (UTF-16) | UTF-8 bytes |
|---|---|---|---|
| a | 1 | 1 | 1 |
| あ (Japanese hiragana) | 1 | 1 | 3 |
| 𠮷 (a variant form of a kanji) | 1 | 2 | 4 |
| 😄 | 1 | 2 | 4 |
| 👨👩👧 (family emoji) | 1 | 8 | 18 |
This tool counts one character as seen as one character. An emoji, or a letter with an accent mark added as a separate character, is one character. It uses the browser's built-in way of splitting text into characters (Intl.Segmenter).
- Characters (not counting line breaks): the number people usually mean by "how many characters". Each space counts as one character.
- Characters (not counting spaces or line breaks): also leaves out spaces, tabs and full-width spaces.
- Lines: the number of pieces separated by line breaks. A line break at the end of the last line doesn't add a line.
- Words: the number of pieces separated by spaces. For English, this is the word count. Japanese has no spaces between words, so for Japanese text it isn't a useful guide.
- Japanese manuscript sheets (400 characters each): in Japan, the length of essays and articles is often given in sheets of manuscript paper with 400 squares. This is the character count (not counting line breaks) divided by 400 and rounded up. Real manuscript paper leaves squares empty at line breaks and indents, so the real number of sheets is higher.
How bytes are counted
The number of bytes depends on the character encoding the text is saved in. When a box says "up to so many bytes", check which encoding it means first.
| Characters | UTF-8 | Shift_JIS |
|---|---|---|
| Half-width letters, digits and symbols | 1 | 1 |
| Half-width katakana | 3 | 1 |
| Hiragana, katakana and most kanji | 3 | 2 |
| Emoji, and some kanji such as 𠮷 | 4 | Can't be converted |
Shift_JIS is a Japanese character encoding that older systems and some Japanese forms still use. This tool counts Shift_JIS bytes with the conversion table built into the browser. Under web standards, shift_jis, windows-31j, ms932 and sjis are all treated as the same encoding, so characters such as ①, ㈱, 髙 and 﨑 also count as 2 bytes.
Characters that aren't in the table can't be converted to Shift_JIS. Besides emoji, these include the wave dash 〜 (U+301C) and the em dash — (U+2014). The full-width tilde ~ (U+FF5E) and the horizontal bar ― (U+2015), which look almost the same, can be converted. When the text contains characters that can't be converted, they're listed in a "Check" note and left out of the byte count.
Line breaks count as 1 byte (LF) at first. To match the size of a file saved with Windows Notepad and similar apps, switch to "2 bytes (CR+LF)".
What it can't do
- Read Word files or PDFs directly: it can only open text files (.txt, .md, .csv and so on). Open the Word file or PDF, copy the text and paste it in.
- Show moved paragraphs as moves: if you move a paragraph, the result shows it removed from the old place and added in the new one.
- Show every line of a very long diff: the screen shows up to 3,000 lines. Longer diffs are still copied in full by "Copy diff".
- Examine long texts that have changed almost everywhere in fine detail: for texts of thousands of lines that are almost entirely different, the comparison may stop partway and show the rest as replaced as a whole, so that the page doesn't freeze for long. The diff is coarser, but it isn't wrong.
FAQ
- Is the text I paste sent anywhere?
- No. Comparing and counting both happen inside your browser. This site is set up so that it can't communicate with anything outside once the page has opened, so there's no way to send it at all.
- Is my text saved?
- No. Close or reload the page and the pasted text is gone, so you can use it for contracts, unpublished manuscripts and other texts you don't want kept. Only settings such as the view are saved, in this browser.
- I only want to count characters
- Paste into just one box and you get the character, line and byte counts. Leave the other box empty.
- Can it read files saved in Shift_JIS or EUC-JP?
- Yes. Drop the file onto a box or choose it with "Open file". It tries UTF-8, Shift_JIS and EUC-JP in that order, and opens the file with the first one that works. Files can be up to 5 MB.
- The count doesn't match other character counters
- Some tools count emoji and some kanji as two characters, because they count the units used inside programs (UTF-16). This tool counts one character as seen as one. Whether line breaks and spaces are counted also makes a difference, so compare the three character counts in the table.
- What does a copied diff look like?
- Each line starts with a mark: "+" for an added line, "-" for a removed line, and a space for an unchanged line. Where a long run of unchanged lines continues, only the two lines on each side are kept.
Sources
- Eugene W. Myers, "An O(ND) Difference Algorithm and Its Variations" (Algorithmica, volume 1, pages 251–266, 1986; how the differences are found)
- Git, "git-diff" (diff settings and the defaults)
- WHATWG, "Encoding Standard" (rules for converting to UTF-8 and Shift_JIS, and the names of encodings)
- WHATWG, "HTML Standard", the textarea element (line breaks in text boxes are turned into LF)
- MDN, "String: length" (the units used inside programs, and characters as seen)
- MDN, "Intl.Segmenter" (splitting text into characters as seen)