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

    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. 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.

    How syntax highlighting works

    The editor does not understand your program. It cuts the text into small pieces called tokens, such as a comment, a string or a keyword, and gives each kind its own color. A string starts at a quote and ends at the next quote that has no backslash before it. So when the rest of a line suddenly turns green, a closing quote is missing. The color is the hint.

    Tabs or spaces?

    Both work, as long as one file uses only one of them. A tab is one character, and each editor decides how wide to show it: 2, 4 or 8 columns. Spaces look the same everywhere. A file that mixes them lines up on one computer and looks broken on the next.

    Beyond that, 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. Go uses tabs, and a Makefile needs a real tab at the start of each command line.

    In this editor the Tab key inserts what you chose in Settings: 2 spaces, 4 spaces or a tab. 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.

    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 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. The status bar here shows which kind the opened file had. Click it to switch, and the file is saved that way.

    Encodings: UTF-8 and the BOM

    Almost every code file today is UTF-8. An English letter takes one byte, é takes two and an emoji takes four. A BOM is three extra bytes that some Windows programs put at the start of a UTF-8 file. You can't see it, but it causes trouble. A PHP file with a BOM sends those bytes to the browser before any header, and many JSON readers reject the file. This editor shows the encoding of an opened file in the status bar and always saves UTF-8 without a BOM.

    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 your code, and it does not check it. A missing semicolon or an unknown variable is not flagged, and there is no autocomplete. JSON is the one exception: the JSON editor points to each error with its line and a fix. For a web page you want to see while you build it, the HTML editor has a visual side and a preview.

    Frequently asked questions

    Can I run my code here?

    No. This page only edits and colors code. To run it, use VS Code on your computer, CodePen or JSFiddle for HTML, CSS and JavaScript, or Replit for Python and most other languages.

    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.

    Can it format or minify my code?

    Yes. Click Format or Minify above the editor. Format fully rewrites JSON, CSS, HTML and XML. For JavaScript, PHP, SQL and the C family it only fixes the indents by brackets. Minify works for JSON, CSS and HTML. Ctrl+Z undoes both.

    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.

    • Text editorWrite and edit text online for free, then convert it to fancy fonts, bold, frames and ASCII art in one click.
    • 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 256 ASCII codes, the 128 standard ones and extended ASCII, 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