In computer programming, boilerplate code or just boilerplate are sections of code that have to be included in many places with little or no alteration. When using languages that are considered verbose, the programmer must write much code to accomplish only minor functionality. Such code is called boilerplate.

The need for boilerplate can be reduced through high-level mechanisms such as metaprogramming (which has the computer automatically write the needed boilerplate code or insert it at compile time), convention over configuration (which provides good default values, reducing the need to specify program details in every project) and model-driven engineering (which uses models and model-to-code generators, eliminating the need for manual boilerplate code).


The term arose from the newspaper business. Columns and other pieces that were distributed by print syndicates were sent to subscribing newspapers in the form of prepared printing plates. Because of their resemblance to the metal plates used in the making of boilers, they became known as “boiler plates”, and their resulting text - “boilerplate text”. As the stories that were distributed by boiler plates were usually “fillers” rather than “serious” news, the term became synonymous with unoriginal, repetitive text.

A related term is bookkeeping code, referring to code that is not part of the business logic but is interleaved with it in order to keep data structures updated or handle secondary aspects of the program.

Boilerlate Example

HTML boilerplate

<html lang="en">
    <meta charset="UTF-8" />

Perl boilerplate

use warnings;
use strict;