
Last checked by the TextEditor.com team
What a code editor does that Notepad does not
Notepad shows every character in the same color and leaves the indentation to you. A code editor reads the text as code. Keywords, strings and comments get their own colors, so a missing quote stands out at once. Press Enter and the new line keeps the indentation of the line above, one level deeper after an opening bracket. Put the cursor next to a bracket and its partner lights up. The line numbers match the numbers in error messages.
- Paste or openDrop a file on the page or press Ctrl+O. The language is picked from the file name or from the content.
- EditTab indents, Ctrl+/ comments a line, Ctrl+H finds and replaces, Alt+Up moves a line up.
- SaveCtrl+S saves the file. In Chrome and Edge it writes back into the file you opened.
Your code saves in this browser as you type, like in the plain text editor. Nothing is sent to our server.
How syntax highlighting works
The editor does not understand your program. It splits the text into tokens: a comment, a string, a number, a keyword, a name, a bracket. Each kind gets a color. The rules are small. A string starts at a quote and ends at the next quote that has no backslash before it. A comment runs from // to the end of the line. Every other word is looked up in a list of keywords.
That is why a broken string turns the rest of its line green: the tokenizer never found the closing quote. The color is the hint. One of the first editors to color code while you typed was LEXX, written in 1985 for the Oxford English Dictionary. See syntax highlighting on Wikipedia for the history.
Comments are gray, strings green, numbers orange, keywords teal. Everything else keeps the ink color.
Tabs or spaces?
Both work. A tab is one character, and every editor decides how wide to show it: 2, 4 or 8 columns. Spaces look the same everywhere, but you need an editor that inserts them for you. The real rule is to pick one and never mix them in one file.
Then follow the language. Python's style guide, PEP 8, asks for 4 spaces per level, and Python 3 refuses to run a block that mixes tabs and spaces. Most JavaScript projects use 2 spaces, which is also the default of the Prettier formatter. Go uses tabs: its gofmt tool rewrites every file that way. A Makefile needs a real tab at the start of each command line.
if x > 0: print(x) # two tabs print(x) # eight spaces, never moves
The two print lines should line up. They only do at one tab width. Mixed files look right on one computer and broken on the next.
In this editor the Tab key inserts what you chose in Settings: 2 spaces, 4 spaces or a tab. The status bar shows the choice. Shift+Tab removes one level.
Line endings: LF and CRLF
The end of a line is a character too. Linux, macOS and the web use one: LF, code 10. Windows uses two: CR then LF, codes 13 and 10. The names come from typewriters, where you returned the carriage and fed the paper one line.
| System | Line ending | Escape | Codes |
|---|---|---|---|
| Windows | CRLF | \r\n | 13, 10 |
| Linux, macOS, Android, the web | LF | \n | 10 |
| Classic Mac OS, before 2001 | CR | \r | 13 |
Most programs read both. Trouble starts when a file mixes them, or when a shell script saved on Windows runs on Linux: the shell sees the extra CR as part of every command and fails with a strange message. Git can swap the endings when you commit (the core.autocrlf setting), which is why a diff sometimes shows every line as changed. The status bar here shows which kind the opened file had. Click it to switch. The file is saved with that kind.
Encodings: UTF-8 and the BOM
A file is bytes, and the encoding says which bytes make which character. Almost every code file today is UTF-8. The English letters take one byte each, while é takes two, 漢 takes three and an emoji takes four. Older Windows files may be Windows-1252, where é is one byte and 漢 cannot be written at all.
A BOM is three bytes, EF BB BF, that some Windows programs put at the start of a UTF-8 file. Most editors hide it, but it breaks things. A PHP file with a BOM sends those bytes to the browser before any header. JSON parsers reject it. A shell script fails on its first line. This editor shows the encoding of an opened file in the status bar and always saves UTF-8 without a BOM.
63 61 66 C3 A9 20 E6 BC A2 20 F0 9F 99 82
8 characters, 14 bytes. Bytes above 7F belong to a character that needs more than one byte.
Keyboard shortcuts
| What it does | Keys |
|---|---|
| Save to a file | Ctrl + S |
| Open a file | Ctrl + O |
| Find, find and replace | Ctrl + F, Ctrl + H |
| All tools | Ctrl + K |
| Indent, outdent | Tab, Shift + Tab (also Ctrl + ] and [) |
| Comment or uncomment the line | Ctrl + / |
| Duplicate the line | Ctrl + D |
| Move the line up or down | Alt + ↑, Alt + ↓ |
| Go to a line | Ctrl + G |
| Leave the editor with the keyboard | Esc, then Tab |
| Undo, redo | Ctrl + Z, Ctrl + Y |
On a Mac, use Cmd instead of Ctrl. Cmd+Option+F opens find and replace. Testing a search pattern? The regex tester shows each match and explains the pattern.
What this editor does not do
It does not run code. There is no Python or Node behind this page, and a browser can only run JavaScript anyway. To run what you wrote, paste it into a real tool: VS Code on your computer (free, and also at vscode.dev in the browser), CodePen or JSFiddle for HTML, CSS and JavaScript, Replit for Python and most other languages. The Python shell at python.org also runs small scripts.
It does not check your code either. A missing semicolon or an unknown variable is not flagged, and there is no autocomplete. The one exception is JSON: the JSON editor explains every error with the line and a fix. For web pages with a visual side, use the HTML editor. For notes with headings and lists, the Markdown editor shows a preview. To see what changed between two versions of a file, compare the two texts.
Other editors for code
- Check and format JSON
{"a":1}The JSON editor explains each error and the line to fix. - Encode or decode textHi → SGk=Base64, URL codes, HTML entities and six more formats.
- Clean up a web page
<b>Hi</b>→ HiThe visual HTML editor tidies code from Word and Google Docs. - Write in Markdown
**bold**→ boldThe Markdown editor shows a live preview as you type.