I have

\chapter{My first chapter}
\chapter{My second chapter}
\phantomsection
\appendix
\makeatletter
\def\toclevel@chapter{1}\def\toclevel@section{2}
\makeatother
\chapter{My first appendix}
\chapter{My second appendix}


So my hyperref ToC look like:

- My first chapter
- My second chapter
+ Appendixes
- My first appendix
- My second appendix


But my \tableofcontents still look like:

1 My first chapter
2 My second chapter
Appendixes
A My first appendix
B My second appendix


And what I want is that the appendixes look like sections:

1 My first chapter
2 My second chapter
Appendixes
A My first appendix
B My second appendix


I can figure out, that there is a really small trick to do the job... but I can't find it...

-
 how about \addcontentsline{toc}{section}{Appendixes}?  – cmhughes Jun 16 '12 at 2:00 Which document class are you using? – Gonzalo Medina Jun 16 '12 at 3:22

set \l@chapter to l@section

\documentclass{book}
\usepackage{hyperref}

\begin{document}

\tableofcontents
\chapter{My first chapter}
\chapter{My second chapter}

\phantomsection
\appendix
\def\toclevel@chapter{1}\def\toclevel@section{2}
\chapter{My first appendix}
\chapter{My second appendix}

\end{document}

-

You can redefine \@chapter (as implemented in the document class used) to use \addcontentsline{toc}{section}{...} instead of \addcontentsline{toc}{chapter}{...}. Here's an example of such redefinition for book.cls:

\documentclass{book}
\usepackage{hyperref}

\begin{document}

\tableofcontents
\chapter{My first chapter}
\chapter{My second chapter}

\phantomsection
\appendix
\makeatletter
\def\@chapter[#1]#2{\ifnum \c@secnumdepth >\m@ne
\if@mainmatter
\refstepcounter{chapter}%
\typeout{\@chapapp\space\thechapter.}%
{\protect\numberline{\thechapter}#1}%
\else
\fi
\else
\fi
\chaptermark{#1}%
\if@twocolumn
\else
\fi}
\makeatother

\chapter{My first appendix}
\chapter{My second appendix}

\end{document}


Here's the resulting ToC:

and the bookmarks pabel:

-
 I want it class independant (like Herbert's answer) – Kyle_the_hacker Jun 18 '12 at 0:04

The following is a condensed version of Gonzalo's answer, using regexpatch. It patches the first appearance of {toc}{chapter} in \Hy@org@chapter with {toc}{section}, yielding the same result:

\documentclass{book}
\usepackage{hyperref}% http://ctan.org/pkg/hyperref
\usepackage{regexpatch}% http://ctan.org/pkg/regexpatch

\begin{document}

\tableofcontents
\chapter{My first chapter}
\chapter{My second chapter}

\phantomsection
`