Decoration libraries
Accessed by \usetikzlibrary{decorations.<name of decoration library>}
Description
As the name says, these libraries decorate a path. Sometimes the path is even substituted with a different path.
Every decoration library is stated below. Use Ctrl + F (Windows) to get to the library you need.
Path morphing decorations
Accessed by \usetikzlibrary{decorations.pathmorphing}
Description [from the TikZ manual]
A path morphing decoration "morphs" or "deforms" the to-be-decorated path. This means that what used to be a straight line might afterwards be a snaking curve and have bumps.
Example
\documentclass[tikz,margin=1]{standalone}
\usetikzlibrary{decorations.pathmorphing}
\def\y{0}
\newcommand\decorated[1]{
\tikzset{decoration=#1}
\draw[thin,red] (0,\y) to[bend left] (1,\y);
\filldraw[decorate,fill=yellow!60,very thick] (0,\y) to[bend left] (1,\y)
node[right,font=\ttfamily] {#1};
\let\auxy\y
\pgfmathsetmacro\y{\auxy+1}
}
\begin{document}
\begin{tikzpicture}[y=-1cm,x=3cm]
\decorated{lineto}
\decorated{straight zigzag}
\decorated{random steps}
\decorated{saw}
\decorated{zigzag}
% We are not able to use our command here :(
\tikzset{decoration=bent}
\draw[thin,red] (0,\y) -- (1,\y);
\filldraw[decorate,fill=yellow!60,very thick] (0,\y) -- (1,\y)
node[right,font=\ttfamily] {bent};
\let\auxy\y
\pgfmathsetmacro\y{\auxy+1}
% %
\decorated{bumps}
\decorated{coil}
\decorated{curveto}
\decorated{snake}
\end{tikzpicture}
\end{document}

Path replacing decorations
Accessed by \usetikzlibrary{decorations.pathreplacing}
Description [from the TikZ manual]
This library defines decorations that replace the to-be-decorated path by another path. Unlike morphing decorations, the replaced path might be quite different, for instance a straight line might be replaced by a set of circles.
Example
Most decorations
\documentclass[tikz,margin=1]{standalone}
\usetikzlibrary{decorations.pathreplacing}
\def\y{0}
\newcommand\decorated[1]{
\tikzset{decoration=#1}
\draw[thin,red] (0,\y) to[bend left] (1,\y);
\draw[decorate,very thick] (0,\y) to[bend left] (1,\y)
node[right,font=\ttfamily] {#1};
\let\auxy\y
\pgfmathsetmacro\y{\auxy+1}
}
\begin{document}
\begin{tikzpicture}[y=-1cm,x=3cm]
\decorated{border}
% We are not able to use our command here :(
\tikzset{decoration=brace}
\draw[thin,red] (0,\y) -- (1,\y);
\draw[decorate,very thick] (0,\y) -- (1,\y)
node[right,font=\ttfamily] {brace};
\let\auxy\y
\pgfmathsetmacro\y{\auxy+3}
% %
\decorated{expanding waves}
\let\auxy\y
\pgfmathsetmacro\y{\auxy+1.5}
\decorated{ticks}
\decorated{waves}
\end{tikzpicture}
\end{document}

The special decoration: show path construction
.
% Source: The TikZ - PGF manual version 3.1.3, May 9 2019, page 636
\documentclass[tikz,margin=1]{standalone}
\usetikzlibrary{decorations.pathreplacing}
\begin{document}
\begin{tikzpicture}[
>=stealth,
every node/.style={midway, sloped, font=\tiny},
decoration={
show path construction,
moveto code={
\fill [red] (\tikzinputsegmentfirst) circle (2pt)
node [fill=none, below] {moveto};},
lineto code={
\draw [blue,->] (\tikzinputsegmentfirst) -- (\tikzinputsegmentlast)
node [above] {lineto};},
curveto code={
\draw [green!75!black,->] (\tikzinputsegmentfirst) .. controls
(\tikzinputsegmentsupporta) and (\tikzinputsegmentsupportb)
..(\tikzinputsegmentlast) node [above] {curveto};},
closepath code={
\draw [orange,->] (\tikzinputsegmentfirst) -- (\tikzinputsegmentlast)
node [above] {closepath};}
}]
\draw [help lines] grid (3,2);
\path [decorate] (0,0) -- (3,1) arc (0:180:1.5 and 1) -- cycle;
\end{tikzpicture}
\end{document}

Arbitrary markings
Accessed by \usetikzlibrary{decorations.markings}
Description [from the TikZ manual]
A marking can be thought of a "little picture" or more precisely of "some scope contents" that is placed "on" a path at a certain position
Example
\documentclass[tikz,margin=1]{standalone}
\usetikzlibrary{decorations.markings}
\begin{document}
\colorlet{darkgreen}{green!70!black}
\begin{tikzpicture}[>=stealth]
\path (0,1) node[right,inner sep=0pt,font=\ttfamily] {markings};
\draw[postaction=decorate,decoration={
markings,
mark=at position 0.5 with \arrow{>}
}] (0,0) -- (3,0) node[right=1ex] {One marking only};
\draw[postaction=decorate,decoration={
markings,
mark=at position 1/3 with {
\draw[red,thick] (-2pt,-2pt) -- (2pt,2pt);
\draw[red,thick] (-2pt,2pt) -- (2pt,-2pt);
},
mark=at position 2/3 with {
\draw[darkgreen,thick] (-2pt,0) -- (0,-2pt) -- (2pt,2pt);
}
}] (0,-1) -- (3,-1) node[right=1ex] {Two markings};
\draw[postaction=decorate,decoration={
markings,
mark=between positions 0 and 1 step 0.2 with {
\filldraw[fill=yellow]
(-3pt,-3pt) -- (3pt,-3pt) -- (0,3pt) -- cycle;
\draw (0,2pt) -- (0,-1pt);
\fill (0,-2pt) circle (.5pt);
}
}] (0,-2) to[bend left] (3,-2) node[right=1ex] {Several markings};
\end{tikzpicture}
\end{document}

Foot prints markings
Accessed by \usetikzlibrary{decorations.footprints}
Description [from the TikZ manual]
The decorations of this library can be used to decorate a path with little footprints, as if someone had "walked" along the path.
Example
\documentclass[tikz,margin=1]{standalone}
\usetikzlibrary{decorations.footprints}
\begin{document}
\begin{tikzpicture}[y=-1.5cm,x=3cm]
\path (0,0) node[right,inner sep=0pt,font=\ttfamily] {footprints};
\foreach \i [count=\j] in {gnome,human,bird,felis silvestris} {
\tikzset{decoration={footprints,foot of=\i}}
\draw[thin,red] (0,\j) to[bend left] (1,\j);
\draw[decorate] (0,\j) to[bend left] (1,\j) node[right] {\i};
}
\end{tikzpicture}
\end{document}

Shape background markings
Accessed by \usetikzlibrary{decorations.shapes}
Description [from the TikZ manual]
N/A
Example
\documentclass[tikz,margin=1]{standalone}
\usetikzlibrary{decorations.shapes}
\def\y{0}
\newcommand\decorated[1]{
\tikzset{decoration=#1}
\draw[thin,red] (0,\y) to[bend left] (1,\y);
\draw[decorate] (0,\y) to[bend left] (1,\y)
node[right,font=\ttfamily] {#1};
\let\auxy\y
\pgfmathsetmacro\y{\auxy+1}
}
\begin{document}
\begin{tikzpicture}[y=-1cm,x=3cm]
\decorated{crosses}
\decorated{triangles}
\decorated{shape backgrounds} % You can customize it. See more in the manual
\end{tikzpicture}
\end{document}

Text decorations
Accessed by \usetikzlibrary{decorations.text}
Description [from the TikZ manual]
The decoration in this library decorates the path with some text. This can be used to draw text that follows a curve.
Example
\documentclass[tikz,margin=2]{standalone}
\usetikzlibrary{decorations.text}
\begin{document}
\begin{tikzpicture}[y=-1cm,x=3cm]
\draw[postaction=decorate,decoration=text along path,
/pgf/decoration/text={Hello world}]
(0,0) to[bend left] (1,0) node[right=1ex,font=\ttfamily] {text along path};
% Source: The TikZ - PGF manual, version 3.1.3, 9 May 2019, page 652
\tikzset{
decoration={
text effects along path,
text={Hello world},
text align=center,
text effects/.cd,
character count=\i,
characters={xslant=0.5, text along path, name=c-\i}
}
}
\draw[postaction=decorate] (0,1) -- (1,3.5)
node[right=1ex,font=\ttfamily] {text effects along path};
\end{tikzpicture}
\end{document}

Fractal decorations
Accessed by \usetikzlibrary{decorations.fractals}
Description [from the TikZ manual]
The decorations of this library can be used to create fractal lines.
Example
\documentclass[tikz,margin=1]{standalone}
\usetikzlibrary{decorations.fractals}
\def\y{0}
\newcommand\decorated[3][]{
\tikzset{decoration=#2}
\draw[ultra thin,red] (0,\y) -- (1,\y);
\draw[#1] decorate {
decorate {
decorate {
(0,\y) -- (1,\y)
}
}
};
\path (1,\y) node[right=1ex,font=\ttfamily] {#2};
\let\auxy\y
\pgfmathsetmacro\y{\auxy+#3}
}
\begin{document}
\begin{tikzpicture}[y=-1cm,x=3cm]
\decorated{Koch curve type 1}{1.5}
\decorated{Koch curve type 2}{2}
\decorated{Koch snowflake}{1}
\decorated[ultra thick]{Cantor set}{0}
\end{tikzpicture}
\end{document}
