To prettyprint (or pretty-print) is to present an object in such a way a to make its structure easier to perceive for to a human reader, or (less commonly) simply to make it more attractive. A prettyprinter is a program that prettyprints. Prettyprinters for programming language source code are sometimes called code beautifiers.


Pretty-printing math

Pretty-printing usually refers to displaying mathematical expressions in a way that is similar to the way they are typeset professionally. For example, in computer algebra systems the system may write output like x ^ 2 + 3 * x as <math>x^2+3x<math>. Mathematical pretty-printing is done by interactive numerical calculation programs such as Octave or MATLAB; by computer algebra systems such as Maxima or Mathematica; and by some graphing calculators, such as the TI-89, or the TI-83 with the PrettyPt ( add-on.

Many text formatting programs can also typeset mathematics: TeX was developed specifically for high-quality mathematical typesetting.

Code formatting and beautification

Programmers often use tools to format their source code in a particular manner. Proper code formatting makes it easier to read and understand. Moreover, often different programmers have different preferred styles of formatting, such as the use of code indentation and whitespace or positioning of braces. A code formatter converts source code from one format style to another. This is relatively straightforward because of the unambiguous syntax of programming languages. Code beautification involves parsing the source code into component structures, such as assignment statements, if blocks, loops, etc (see also control flow), and formatting them in a manner specified by the user in a configuration file.

There exist both standalone code beautifiers and built in ones in integrated development environments (IDEs). For example, Microsoft Visual Studio's source code editor does some limited code formatting like indenting blocks of code inside of braces properly.

An early example of pretty-printing was Bill Gosper's "GRIND" program, which used combinatorial search with pruning to format LISP programs. The term "grind" was used in some Lisp circles as a synonym for pretty-printing.

Example of formatting and beautifying code

int foo(int k) {
  if(k==11) printf("hello\n");
   else printf("good bye\n");
int foo(int k)  
   if( k == 11 )
     printf("good bye\n");
int foo(int k){if(k==11)printf("hello\n");else printf("good bye\n");}

These three C programs mean the same thing and parse in exactly the same manner since they consist of the same sequence of tokens, differing only in whitespace. Example 1 reflects one preference, example 2 another one, and example 3 is another style which some might find less easy to read. A code beautifier will convert any of these into a format preferred by the programmer.

Text formatting

Text formatting can be considered a form of pretty-printing.

Pretty printers


  • Art and Cultures
    • Art (
    • Architecture (
    • Cultures (
    • Music (
    • Musical Instruments (
  • Biographies (
  • Clipart (
  • Geography (
    • Countries of the World (
    • Maps (
    • Flags (
    • Continents (
  • History (
    • Ancient Civilizations (
    • Industrial Revolution (
    • Middle Ages (
    • Prehistory (
    • Renaissance (
    • Timelines (
    • United States (
    • Wars (
    • World History (
  • Human Body (
  • Mathematics (
  • Reference (
  • Science (
    • Animals (
    • Aviation (
    • Dinosaurs (
    • Earth (
    • Inventions (
    • Physical Science (
    • Plants (
    • Scientists (
  • Social Studies (
    • Anthropology (
    • Economics (
    • Government (
    • Religion (
    • Holidays (
  • Space and Astronomy
    • Solar System (
    • Planets (
  • Sports (
  • Timelines (
  • Weather (
  • US States (


  • Home Page (
  • Contact Us (

  • Clip Art (
Personal tools