FormatterHQ

Source Code Viewer

Open a code file or paste code to read it with syntax highlighting and line numbers. The language can be detected automatically, and nothing is uploaded.

Input TEXT
Output HTML
Ready.

How to use the Source Code Viewer

  1. Open a source file from your computer or paste code into the editor.
  2. Leave the language on auto-detect or pick it from the list.
  3. Choose a light or dark theme and toggle line numbers.
  4. Read the highlighted code in the preview; the status line shows lines and characters.

A source code viewer for reading code anywhere

Code in a plain text window is a gray wall of characters. Syntax highlighting colors keywords, strings, comments and numbers differently, so the structure jumps out and mistakes like an unclosed string become obvious. This source code viewer adds highlighting and line numbers to any snippet or file, which is handy on a machine without an IDE, for reviewing an email attachment, or when a colleague asks you to "look at line 42".

Supported languages

JavaScript, TypeScript, HTML, XML, CSS, PHP, Python, Java, C, C++, C#, Go, Rust, Ruby, Kotlin, Swift, SQL and shell scripts. When the language is left empty, the viewer makes a quick guess from the first lines: <?php means PHP, a leading < means HTML, def or import suggests Python, SELECT suggests SQL and selector { suggests CSS. Everything else is treated as JavaScript-like code. Pick the language manually if the guess is wrong.

Example

<?php

namespace App\Http\Controllers;

use App\Models\Post;

class PostController extends Controller
{
    public function show(Post $post)
    {
        return view('posts.show', ['post' => $post]);
    }
}

With auto-detect, this is recognized as PHP; keywords such as namespace, class and return are colored, strings stand out and each line is numbered.

Options

  • Language – auto-detect or choose one of the supported languages.
  • Theme – light or dark, whichever is easier on your eyes.
  • Line numbers – on by default, essential when discussing code with others.

The status line shows the number of lines and characters, a quick way to check a file's size.

When a viewer beats an editor

A viewer shows the code read-only, so you cannot accidentally change a file you only meant to read. It also opens instantly without project setup, which is ideal for quick reviews during a call or on a device where you do not have your usual tools.

Viewing code safely

The viewer only displays code; it never executes it. That makes it a safe way to inspect scripts you received, for example a shell script someone asked you to run. Read it first, and do not run commands you do not understand.

Related tools

Files are read by your browser and never uploaded.

Frequently asked questions

Which file types can I open?
Any text-based source file, such as .js, .ts, .php, .py, .java, .c, .cs, .go, .rs, .rb, .sql, .css, .html or .sh. Binary files like compiled programs cannot be displayed.
How does language detection work?
The viewer looks at the beginning of the code for telltale signs, such as a PHP opening tag, HTML angle brackets or Python def statements. If it guesses wrong, choose the language manually.
Does the viewer run my code?
No. It only highlights and displays text, so it is safe for inspecting scripts you do not trust.
Can I copy the highlighted code?
You can copy the code text. For highlighted HTML with inline colors that you can paste elsewhere, use the code syntax highlighter.

Last updated September 26, 2026

Related tools

Code Syntax Highlighter Highlight source code as self-contained HTML with inline styles - paste the coloured snippet into blogs, e-mails or docs. Online Code Editor Multi-language online code editor with syntax highlighting for 30+ languages. Open, edit, save and download code files. BBCode Viewer Preview BBCode forum posts before publishing: bold, colours, links, quotes, lists, code and spoilers rendered live. CSV Viewer View CSV files as a clean, sortable-looking table in your browser. Auto-detects commas, semicolons, pipes and tabs. Excel Viewer Open and view Excel (.xlsx, .xls), OpenDocument (.ods) and CSV spreadsheets online without Excel. Sheet tabs, merged cells and JSON tree. EXIF Viewer Read EXIF, GPS, XMP, IPTC and ICC metadata from photos — camera, lens, exposure, date and location — without uploading the file. SVG Viewer Preview SVG code or files instantly, check them for XML errors, see width, height and viewBox, and download the image. Area Chart Maker Create area charts online from CSV or JSON data: filled line graphs with multiple series, smooth curves and SVG export. Bar Graph Maker Make bar charts online from CSV or JSON. Grouped bars for multiple series, negative values, custom colours and SVG export. Doughnut Chart Maker Build doughnut (donut) charts online from CSV or JSON. Shows the total in the centre, percentages per segment and exports SVG. Online HTML Editor Write and edit HTML with autocompletion and a sandboxed live preview, then copy or download the finished document. HTML Viewer Paste HTML or open a file and see it rendered instantly in a safe, sandboxed live preview. Free online HTML viewer.