whatisgithub

What is code-prettify?

googlearchive/code-prettify — explained in plain English

Analysis updated 2026-06-26

5,769JavaScriptAudience · developerComplexity · 1/5Setup · easy

In one sentence

An archived JavaScript library from Google that adds color-coded syntax highlighting to code blocks on any web page, include one script tag, add a CSS class to your code element, and the language is detected automatically.

Mindmap

mindmap
  root((code-prettify))
    What it does
      Syntax highlighting
      Auto language detect
      CSS theming
    Languages Supported
      Python Java C
      JavaScript HTML
      Go Rust Ruby
    Use Cases
      Static HTML pages
      Blog code snippets
      Legacy CMS sites
    Setup
      One script tag
      One CSS class
    Status
      Archived by Google
      No longer maintained
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

What do people build with it?

USE CASE 1

Add syntax highlighting to a static HTML documentation site without a build step or npm dependency.

USE CASE 2

Display code samples with automatic language detection on a blog or CMS that allows injecting a script tag.

USE CASE 3

Study the archived codebase as a reference for how tokenizer-based syntax highlighting was implemented in plain JavaScript.

What is it built with?

JavaScriptCSS

How does it compare?

googlearchive/code-prettifybretfisher/udemy-docker-masteryfilipeps/traduzir-paginas-web
Stars5,7695,7685,771
LanguageJavaScriptJavaScriptJavaScript
Setup difficultyeasymoderateeasy
Complexity1/53/51/5
Audiencedeveloperops devopsgeneral

Figures from each repo's GitHub metadata at analysis time.

How do you get it running?

Difficulty · easy Time to first run · 5min

This project is archived and no longer maintained, consider highlight.js or Prism.js for new projects.

So what is it?

Code Prettify is an archived JavaScript library originally created by Google that adds syntax highlighting to code snippets displayed on web pages. Syntax highlighting means coloring different parts of code (keywords, strings, comments, etc.) so they are easier to read visually. This library is no longer maintained, and the repository is marked as inactive. To use it, you include a single script tag in your HTML page and then mark any block of code with the class "prettyprint". The library automatically detects what programming language the code is written in and applies appropriate colors, so you do not have to specify the language yourself. You can optionally specify a language extension if you want to override that detection. Line numbers can be added with a separate class, and the visual styles can be changed through CSS. The library works with a wide range of languages out of the box, including C, C++, Java, Python, Bash, JavaScript, HTML, XML, CSS, SQL, and Rust. Additional language extensions are included in the repository for languages like Go, Haskell, Scala, Swift, Lua, Ruby, and YAML, among others. It handles code that contains embedded HTML links or other markup without breaking the display. The library was used in production on both Google Code and Stack Overflow, according to the README. It was tested with older browser versions including Internet Explorer 6 and early versions of Firefox and Safari. The README includes answers to several practical questions: how to prevent specific sections from being highlighted, how to control line numbering, how to handle code coming from Markdown renderers that do not allow adding CSS classes, and why it may behave unexpectedly on WordPress sites. Because this project is archived and no longer maintained, developers looking for an actively supported syntax highlighting library would need to look elsewhere.

Copy-paste prompts

Prompt 1
Show me the minimal HTML to include code-prettify on a static page and display a Python code block with syntax highlighting and line numbers.
Prompt 2
I am migrating from code-prettify to highlight.js. Show me what code-prettify markup looks like and what the equivalent highlight.js markup would be.
Prompt 3
How does code-prettify detect the programming language of a code block automatically, and how do I override that detection for a language it misidentifies?
Prompt 4
Show me how to apply a custom color theme to code-prettify by overriding its CSS classes.

Frequently asked questions

What is code-prettify?

An archived JavaScript library from Google that adds color-coded syntax highlighting to code blocks on any web page, include one script tag, add a CSS class to your code element, and the language is detected automatically.

What language is code-prettify written in?

Mainly JavaScript. The stack also includes JavaScript, CSS.

How hard is code-prettify to set up?

Setup difficulty is rated easy, with roughly 5min to a first successful run.

Who is code-prettify for?

Mainly developer.

Open on GitHub → Ask about another repo

This repo across BitVibe Labs

Verify against the repo before relying on details.