SourceFormatX

CodeMorph

CodeToHtml

Overview

Features

Code To HTML

Output Styles

Screenshots

FAQs & Tips

Update History

License Policy

Convert Code To HTML


CodeToHtml code to html converter is a handy tool for programmers and web developers, that allows you to easily convert your source code to HTML code, XHTML code, BBCode code, RTF files, TeX files with colorful syntax highlighting.

CodeToHtml code to html converter controls well with all special characters like <, >, &, etc. So the converted HTML code and XHTML code can be put directly inside the <pre></pre> tags to maintain the default code formatting.

  Original Source Code

   /* Convert Code To HTML */

   int foo(int x)
   {
     if (x == 1)
       printf("hello!\n");
     else
       printf("good bye!\n");
   }

  Convert Code to HTML

<pre> <code><span style="font: 10pt Courier New"><font color="#000000"> </font><font color="#008000">/* Convert Code To HTML */</font><font color="#000000"> </font><font color="#0000FF">int</font><font color="#000000"> foo</font><font color="#000080">(</font><font color="#0000FF">int</font><font color="#000000"> x</font><font color="#000080">) </font><font color="#000000"> </font><font color="#000080">{ </font><font color="#000000"> </font><font color="#0000FF">if</font><font color="#000000"> </font><font color="#000080">(</font><font color="#000000">x </font><font color="#000080">==</font><font color="#000000"> </font><font color="#800080">1</font><font color="#000080">) </font><font color="#000000"> printf</font><font color="#000080">(</font><font color="#800000">&quot;hello!\n&quot;</font><font color="#000080">); </font><font color="#000000"> </font><font color="#0000FF">else </font><font color="#000000"> printf</font><font color="#000080">(</font><font color="#800000">&quot;good bye!\n&quot;</font><font color="#000080">); </font><font color="#000000"> </font><font color="#000080">}</font></span></code> </pre>

  Convert Code to XHTML

<pre><code><span style="font: 10pt Courier New;"><span class="cpp1-whitespace"> </span><span class="cpp1-comment">/* Convert Code To HTML */ </span><span class="cpp1-whitespace"> </span><span class="cpp1-keyword">int</span><span class="cpp1-whitespace"> foo</span><span class="cpp1-symbol">(</span><span class="cpp1-keyword">int</span><span class="cpp1-whitespace"> x</span><span class="cpp1-symbol">) </span><span class="cpp1-whitespace"> </span><span class="cpp1-symbol">{ </span><span class="cpp1-whitespace"> </span><span class="cpp1-keyword">if</span><span class="cpp1-whitespace"> </span><span class="cpp1-symbol">(</span><span class="cpp1-identifier">x </span><span class="cpp1-symbol">==</span><span class="cpp1-whitespace"> </span><span class="cpp1-number">1</span><span class="cpp1-symbol">) </span><span class="cpp1-whitespace"> printf</span><span class="cpp1-symbol">(</span><span class="cpp1-string">&quot;hello!\n&quot;</span><span class="cpp1-symbol">); </span><span class="cpp1-whitespace"> </span><span class="cpp1-keyword">else </span><span class="cpp1-whitespace"> printf</span><span class="cpp1-symbol">(</span><span class="cpp1-string">&quot;good bye!\n&quot;</span><span class="cpp1-symbol">); </span><span class="cpp1-whitespace"> </span><span class="cpp1-symbol">}</span></span></code></pre>

  Convert Code to BBCode

[color=#008000]/* Convert Code To HTML */[/color][color=#0000FF]int[/color][color=#000000] foo[/color][color=#000080]([/color][color=#0000FF]int[/color][color=#000000] x[/color][color=#000080]) {[/color][color=#000000] [/color][color=#0000FF]if[/color][color=#000000] [/color][color=#000080]([/color][color=#000000]x [/color][color=#000080]==[/color][color=#000000] [/color][color=#800080]1[/color][color=#000080]) [/color][color=#000000] printf[/color][color=#000080]([/color][color=#800000]"hello!\n"[/color][color=#000080]);[/color][color=#000000] [/color][color=#0000FF]else [/color][color=#000000] printf[/color][color=#000080]([/color][color=#800000]"good bye!\n"[/color][color=#000080]);}[/color]

  Convert Code to RTF

{\rtf1\ansi\deff0\deftab720{\fonttbl{\f0\fmodern Courier New;}} {\colortbl\red0\green128\blue0;\red0\green0\blue255;\red0\green0\blue0;\red0\green0\blue128;\red128\green0\blue128;\red128\green0\blue0;} {\info{\comment generated by the SourceFormatX RTF Generator} {\title c.c}} \deflang1033\pard\plain\f0\fs20 \cf0 /* Convert Code To HTML */ \par \par \cf1 int\cf2 foo\cf3 (\cf1 int\cf2 x\cf3 ) \par \{ \par \cf2 \cf1 if\cf2 \cf3 (\cf2 x \cf3 ==\cf2 \cf4 1\cf3 ) \par \cf2 printf\cf3 (\cf5 "hello!\\n"\cf3 ); \par \cf2 \cf1 else \par \cf2 printf\cf3 (\cf5 "good bye!\\n"\cf3 ); \par \} \par }

  Convert Code to TeX

\documentclass[a4paper, 10pt]{article} \usepackage[a4paper, margin=2cm]{geometry} \usepackage[T1]{fontenc} \usepackage{color} \usepackage{alltt} \usepackage{times} \usepackage{ulem} \usepackage[ansinew]{inputenc} % Special Characters \newcommand\SPC{\hspace*{0.6em}} \newcommand\TAB{\hspace*{1.2em}} \newcommand\BS{\mbox{\char 92}} \newcommand\TLD{\mbox{\char 126}} \newcommand\CIR{\mbox{\char 94}} \newcommand\HYP{\mbox{\char 45}} \newcommand\QOT{\mbox{\char 34}} \newcommand{\uln}[1]{\bgroup \markoverwith{\hbox{\_}}\ULon{{#1}}} % Highlighter Attributes \newcommand{\CppAAssembler}[1]{\textcolor[rgb]{0,0.31,0.75}{#1}} \newcommand{\CppACharacter}[1]{\textcolor[rgb]{0.63,0,0}{#1}} \newcommand{\CppAComment}[1]{\textcolor[rgb]{0,0.5,0}{#1}} \newcommand{\CppADoxygen}[1]{\textcolor[rgb]{0,0.5,0.5}{#1}} \newcommand{\CppADoxygenKeyword}[1]{\textcolor[rgb]{0,0.31,0.75}{#1}} \newcommand{\CppAFloat}[1]{\textcolor[rgb]{0,0.4,0.6}{#1}} \newcommand{\CppAHexadecimal}[1]{\textcolor[rgb]{0,0,0.63}{#1}} \newcommand{\CppAIdentifier}[1]{\textcolor[rgb]{0,0,0}{#1}} \newcommand{\CppAIllegalChar}[1]{\textcolor[rgb]{1,0,0}{#1}} \newcommand{\CppAKeyword}[1]{\textcolor[rgb]{0,0,1}{#1}} \newcommand{\CppANumber}[1]{\textcolor[rgb]{0.5,0,0.5}{#1}} \newcommand{\CppAOctal}[1]{\textcolor[rgb]{0,0.4,0.4}{#1}} \newcommand{\CppAOpenGL}[1]{\textcolor[rgb]{0.5,0,1}{#1}} \newcommand{\CppAPreprocessor}[1]{\textcolor[rgb]{0,0,1}{#1}} \newcommand{\CppASourceFormatXTag}[1]{\textcolor[rgb]{0.5,0.5,0.5}{#1}} \newcommand{\CppAString}[1]{\textcolor[rgb]{0.5,0,0}{#1}} \newcommand{\CppASymbol}[1]{\textcolor[rgb]{0,0,0.5}{#1}} \newcommand{\CppAWhitespace}[1]{#1} \title{c.c} % Generated by SourceFormatX TeX Generator \begin{document} \begin{ttfamily} \noindent \CppAComment{/*\SPC Convert\SPC Code\SPC To\SPC HTML\SPC */}\\ \\ \CppAKeyword{int}\CppAWhitespace{\SPC }\CppAIdentifier{foo}\CppASymbol{(}\CppAKeyword{int}\CppAWhitespace{\SPC }\CppAIdentifier{x}\CppASymbol{)}\\ \CppASymbol{\{}\\ \CppAWhitespace{\SPC }\CppAKeyword{if}\CppAWhitespace{\SPC }\CppASymbol{(}\CppAIdentifier{x}\CppAWhitespace{\SPC }\CppASymbol{==}\CppAWhitespace{\SPC }\CppANumber{1}\CppASymbol{)}\\ \CppAWhitespace{\SPC \SPC \SPC }\CppAIdentifier{printf}\CppASymbol{(}\CppAString{\QOT hello!\BS n\QOT }\CppASymbol{)}\CppASymbol{;}\\ \CppAWhitespace{\SPC }\CppAKeyword{else}\\ \CppAWhitespace{\SPC \SPC \SPC }\CppAIdentifier{printf}\CppASymbol{(}\CppAString{\QOT good\SPC bye!\BS n\QOT }\CppASymbol{)}\CppASymbol{;}\\ \CppASymbol{\}}\\ \end{ttfamily} \end{document}