Skip to content

Online code editor

Write or paste code and see it with colors and line numbers. Format it and save it. Nothing leaves your browser.

Ln 1, Col 1UTF-8Saved in this browser
This editor does not run code. For JSON with error checking, use the JSON editor. For plain notes, the text editor.

    Commands work on the whole document. Ctrl Z undoes them.

    Advertisement
    A sheet of paper with lines of code, line numbers in the margin and curly brackets

    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.

    1. Paste or openDrop a file on the page or press Ctrl+O. The language is picked from the file name or from the content.
    2. EditTab indents, Ctrl+/ comments a line, Ctrl+H finds and replaces, Alt+Up moves a line up.
    3. 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.

    Watch the tokens

    
    

    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.

    The same file with tabs, shown at three tab widths
    	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.

    SystemLine endingEscapeCodes
    WindowsCRLF\r\n13, 10
    Linux, macOS, Android, the webLF\n10
    Classic Mac OS, before 2001CR\r13

    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.

    Text as UTF-8 bytes
    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 doesKeys
    Save to a fileCtrl + S
    Open a fileCtrl + O
    Find, find and replaceCtrl + F, Ctrl + H
    All toolsCtrl + K
    Indent, outdentTab, Shift + Tab (also Ctrl + ] and [)
    Comment or uncomment the lineCtrl + /
    Duplicate the lineCtrl + D
    Move the line up or downAlt + ↑, Alt + ↓
    Go to a lineCtrl + G
    Leave the editor with the keyboardEsc, then Tab
    Undo, redoCtrl + 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

    Frequently asked questions

    Is this code editor free? Do I need to sign up?

    It is free, and there is no account. Open the page and start typing. Ads on the page pay for the site.

    Can I run my code here?

    No. This page only edits and colors code. To run it, use VS Code, CodePen, JSFiddle or Replit, or the tools of the language on your own computer.

    Which languages get colors?

    HTML, CSS, JavaScript, TypeScript, JSON, Python, PHP, SQL, Markdown, XML, YAML, Bash, and the C family: C, C++, Java, C#, Go, Rust, Swift and Kotlin. Other files open as plain text.

    Where is my code saved?

    In this browser, on this device. It is never sent to our server. Press Ctrl+S to save a file, because clearing the browsing data for this site removes the saved copy.

    Why did the colors and line numbers stop?

    Above 300,000 characters the color layer turns off, so typing stays fast. Editing, find, save and format still work. Split a very big file, or use a desktop editor.

    How do I turn text into Base64 or URL encoding?

    Use the encoder and decoder. It works both ways as you type and handles emoji and accents correctly.

    • Text editorWrite and edit plain text in your browser.
    • Text comparePaste two texts and see every changed line and word highlighted side by side.
    • Find and replaceFind and replace words in any text, with match case, whole words and regex.
    • ASCII tableAll 128 ASCII codes with decimal, hex, octal, binary and HTML values.
    • All charactersFind any Unicode character by name or code, copy it, and get its HTML entity, CSS and JavaScript code.
    • CSV editorOpen a CSV file in a grid, fix cells, sort, add or delete rows and save it as CSV, Excel, JSON or a Markdown table.

    ↑ ↓ to choose, Enter to open, Esc to close