I’m looking for a way to convert few paragraphs and ordered/unordered lists from a MS Word file to HTML.
Now, the problem is that when saving the Word file as a «htm/html» type of file (I’m using Word 2010), I get tons of all kinds of unwanted CSS directives, some are MS-invented and some are valid CSS, that I don’t want in my html code. Moreover, and even more problematic, the ordered/unordered lists not even encoded to OL and UL with LI items, rather to a crazy Microsofty encoding.
For example, a paragraph (Styled as «Normal» in Word) is converted to:
<p class=MsoNormal>
<span style='font-size:10.0pt;line-height:115%;mso-bidi-font-style:italic'>
bla bla </span></p>
And I just want it to plainly be:
<p><span>bla bla</span></p>
More horrific, a simple unoredered list («bulleted list») with one list item with is converted to:
<p class=MsoListParagraph style='text-indent:-18.0pt;mso-list:l0 level1 lfo1'>
<![if !supportLists]>
<span style='font-family:Symbol;mso-fareast-font-family:Symbol;mso-bidi-font-family:Symbol'>
<span style='mso-list:Ignore'>·
<span style='font:7.0pt "Times New Roman"'>
</span></span></span><![endif]>
<span dir=LTR</span>Bla bla</p>
While I wish to get:
<ul><li>Bla bla</li></ul>
Any ideas?
Thanks so much!
p.s. I’m using Zend Studio (maybe there’s a built in eclipse/zend-specific converter or something?)
p.s.p. The only MS Word options for exporting as html I’ve found are in Options => Advanced => General => Web Options. Playing with these options didn’t solve any of the above problems.
Mammoth .docx to HTML converter
Mammoth is designed to convert .docx documents,
such as those created by Microsoft Word, Google Docs and LibreOffice,
and convert them to HTML.
Mammoth aims to produce simple and clean HTML by using semantic information in the document,
and ignoring other details.
For instance,
Mammoth converts any paragraph with the style Heading 1
to h1
elements,
rather than attempting to exactly copy the styling (font, text size, colour, etc.) of the heading.
There’s a large mismatch between the structure used by .docx and the structure of HTML,
meaning that the conversion is unlikely to be perfect for more complicated documents.
Mammoth works best if you only use styles to semantically mark up your document.
The following features are currently supported:
-
Headings.
-
Lists.
-
Customisable mapping from your own docx styles to HTML.
For instance, you could convertWarningHeading
toh1.warning
by providing an appropriate style mapping. -
Tables.
The formatting of the table itself, such as borders, is currently ignored,
but the formatting of the text is treated the same as in the rest of the document. -
Footnotes and endnotes.
-
Images.
-
Bold, italics, underlines, strikethrough, superscript and subscript.
-
Links.
-
Line breaks.
-
Text boxes. The contents of the text box are treated as a separate paragraph
that appears after the paragraph containing the text box. -
Comments.
Web demo
The easiest way to try out mammoth is to use the web demo:
- Clone this repository
- Run
make setup
- Open
browser-demo/index.html
in a web browser
Installation
Other supported platforms
-
Python.
Available on PyPI. -
WordPress.
-
Java/JVM.
Available on Maven Central. -
.NET.
Available on NuGet.
Usage
CLI
You can convert docx files by passing the path to the docx file and the output file.
For instance:
mammoth document.docx output.html
If no output file is specified, output is written to stdout instead.
The output is an HTML fragment, rather than a full HTML document, encoded with UTF-8.
Since the encoding is not explicitly set in the fragment,
opening the output file in a web browser may cause Unicode characters to be rendered incorrectly if the browser doesn’t default to UTF-8.
Images
By default, images are included inline in the output HTML.
If an output directory is specified by --output-dir
,
the images are written to separate files instead.
For instance:
mammoth document.docx --output-dir=output-dir
Existing files will be overwritten if present.
Styles
A custom style map can be read from a file using --style-map
.
For instance:
mammoth document.docx output.html --style-map=custom-style-map
Where custom-style-map
looks something like:
p[style-name='Aside Heading'] => div.aside > h2:fresh
p[style-name='Aside Text'] => div.aside > p:fresh
A description of the syntax for style maps can be found in the section «Writing style maps».
Markdown
Markdown support is deprecated.
Generating HTML and using a separate library to convert the HTML to Markdown is recommended,
and is likely to produce better results.
Using --output-format=markdown
will cause Markdown to be generated.
For instance:
mammoth document.docx --output-format=markdown
Library
In node.js, mammoth can be required in the usual way:
var mammoth = require("mammoth");
This also works in the browser if node.js core modules
such as Buffer
and Stream
, are polyfilled.
Some bundlers, such as Webpack before version 5, will automatically polyfill these modules,
while others, such as Webpack from version 5, require the polyfills to be explicitly configured.
Alternatively, you may use the standalone JavaScript file mammoth.browser.js
,
which includes both mammoth and its dependencies.
This uses any loaded module system.
For instance, when using CommonJS:
var mammoth = require("mammoth/mammoth.browser");
If no module system is found,
mammoth
is set as a window global.
The file can be generated using make setup
during development.
Basic conversion
To convert an existing .docx file to HTML, use mammoth.convertToHtml
:
var mammoth = require("mammoth"); mammoth.convertToHtml({path: "path/to/document.docx"}) .then(function(result){ var html = result.value; // The generated HTML var messages = result.messages; // Any messages, such as warnings during conversion }) .catch(function(error) { console.error(error); });
Note that mammoth.convertToHtml
returns a promise.
You can also extract the raw text of the document by using mammoth.extractRawText
.
This will ignore all formatting in the document.
Each paragraph is followed by two newlines.
mammoth.extractRawText({path: "path/to/document.docx"}) .then(function(result){ var text = result.value; // The raw text var messages = result.messages; }) .catch(function(error) { console.error(error); });
Custom style map
By default,
Mammoth maps some common .docx styles to HTML elements.
For instance,
a paragraph with the style name Heading 1
is converted to a h1
element.
You can pass in a custom map for styles by passing an options object with a styleMap
property as a second argument to convertToHtml
.
A description of the syntax for style maps can be found in the section «Writing style maps».
For instance, if paragraphs with the style name Section Title
should be converted to h1
elements,
and paragraphs with the style name Subsection Title
should be converted to h2
elements:
var mammoth = require("mammoth"); var options = { styleMap: [ "p[style-name='Section Title'] => h1:fresh", "p[style-name='Subsection Title'] => h2:fresh" ] }; mammoth.convertToHtml({path: "path/to/document.docx"}, options);
To more easily support style maps stored in text files,
styleMap
can also be a string.
Each line is treated as a separate style mapping,
ignoring blank lines and lines starting with #
:
var options = { styleMap: "p[style-name='Section Title'] => h1:freshn" + "p[style-name='Subsection Title'] => h2:fresh" };
User-defined style mappings are used in preference to the default style mappings.
To stop using the default style mappings altogether,
set options.includeDefaultStyleMap
to false
:
var options = { styleMap: [ "p[style-name='Section Title'] => h1:fresh", "p[style-name='Subsection Title'] => h2:fresh" ], includeDefaultStyleMap: false };
Custom image handlers
By default, images are converted to <img>
elements with the source included inline in the src
attribute.
This behaviour can be changed by setting the convertImage
option to an image converter .
For instance, the following would replicate the default behaviour:
var options = { convertImage: mammoth.images.imgElement(function(image) { return image.read("base64").then(function(imageBuffer) { return { src: "data:" + image.contentType + ";base64," + imageBuffer }; }); }) };
Bold
By default, bold text is wrapped in <strong>
tags.
This behaviour can be changed by adding a style mapping for b
.
For instance, to wrap bold text in <em>
tags:
var mammoth = require("mammoth"); var options = { styleMap: [ "b => em" ] }; mammoth.convertToHtml({path: "path/to/document.docx"}, options);
Italic
By default, italic text is wrapped in <em>
tags.
This behaviour can be changed by adding a style mapping for i
.
For instance, to wrap italic text in <strong>
tags:
var mammoth = require("mammoth"); var options = { styleMap: [ "i => strong" ] }; mammoth.convertToHtml({path: "path/to/document.docx"}, options);
Underline
By default, the underlining of any text is ignored since underlining can be confused with links in HTML documents.
This behaviour can be changed by adding a style mapping for u
.
For instance, suppose that a source document uses underlining for emphasis.
The following will wrap any explicitly underlined source text in <em>
tags:
var mammoth = require("mammoth"); var options = { styleMap: [ "u => em" ] }; mammoth.convertToHtml({path: "path/to/document.docx"}, options);
Strikethrough
By default, strikethrough text is wrapped in <s>
tags.
This behaviour can be changed by adding a style mapping for strike
.
For instance, to wrap strikethrough text in <del>
tags:
var mammoth = require("mammoth"); var options = { styleMap: [ "strike => del" ] }; mammoth.convertToHtml({path: "path/to/document.docx"}, options);
Comments
By default, comments are ignored.
To include comments in the generated HTML,
add a style mapping for comment-reference
.
For instance:
var mammoth = require("mammoth"); var options = { styleMap: [ "comment-reference => sup" ] }; mammoth.convertToHtml({path: "path/to/document.docx"}, options);
Comments will be appended to the end of the document,
with links to the comments wrapped using the specified style mapping.
API
mammoth.convertToHtml(input, options)
Converts the source document to HTML.
-
input
: an object describing the source document.
On node.js, the following inputs are supported:{path: path}
, wherepath
is the path to the .docx file.{buffer: buffer}
, wherebuffer
is a node.js Buffer containing a .docx file.
In the browser, the following inputs are supported:
{arrayBuffer: arrayBuffer}
, wherearrayBuffer
is an array buffer containing a .docx file.
-
options
(optional): options for the conversion.
May have the following properties:-
styleMap
: controls the mapping of Word styles to HTML.
Ifoptions.styleMap
is a string,
each line is treated as a separate style mapping,
ignoring blank lines and lines starting with#
:
Ifoptions.styleMap
is an array,
each element is expected to be a string representing a single style mapping.
See «Writing style maps» for a reference to the syntax for style maps. -
includeEmbeddedStyleMap
: by default,
if the document contains an embedded style map, then it is combined with the default style map.
To ignore any embedded style maps,
setoptions.includeEmbeddedStyleMap
tofalse
. -
includeDefaultStyleMap
: by default,
the style map passed instyleMap
is combined with the default style map.
To stop using the default style map altogether,
setoptions.includeDefaultStyleMap
tofalse
. -
convertImage
: by default, images are converted to<img>
elements with the source included inline in thesrc
attribute.
Set this option to an image converter to override the default behaviour. -
ignoreEmptyParagraphs
: by default, empty paragraphs are ignored.
Set this option tofalse
to preserve empty paragraphs in the output. -
idPrefix
:
a string to prepend to any generated IDs,
such as those used by bookmarks, footnotes and endnotes.
Defaults to an empty string. -
transformDocument
: if set,
this function is applied to the document read from the docx file before the conversion to HTML.
The API for document transforms should be considered unstable.
See document transforms.
-
-
Returns a promise containing a result.
This result has the following properties:-
value
: the generated HTML -
messages
: any messages, such as errors and warnings, generated during the conversion
-
mammoth.convertToMarkdown(input, options)
Markdown support is deprecated.
Generating HTML and using a separate library to convert the HTML to Markdown is recommended,
and is likely to produce better results.
Converts the source document to Markdown.
This behaves the same as convertToHtml
,
except that the value
property of the result contains Markdown rather than HTML.
mammoth.extractRawText(input)
Extract the raw text of the document.
This will ignore all formatting in the document.
Each paragraph is followed by two newlines.
-
input
: an object describing the source document.
On node.js, the following inputs are supported:{path: path}
, wherepath
is the path to the .docx file.{buffer: buffer}
, wherebuffer
is a node.js Buffer containing a .docx file.
In the browser, the following inputs are supported:
{arrayBuffer: arrayBuffer}
, wherearrayBuffer
is an array buffer containing a .docx file.
-
Returns a promise containing a result.
This result has the following properties:-
value
: the raw text -
messages
: any messages, such as errors and warnings
-
mammoth.embedStyleMap(input, styleMap)
Given an existing docx file,
embedStyleMap
will generate a new docx file with the passed style map embedded.
When the new docx file is read by Mammoth,
it will use the embedded style map.
-
input
: an object describing the source document.
On node.js, the following inputs are supported:{path: path}
, wherepath
is the path to the .docx file.{buffer: buffer}
, wherebuffer
is a node.js Buffer containing a .docx file.
In the browser, the following inputs are supported:
{arrayBuffer: arrayBuffer}
, wherearrayBuffer
is an array buffer containing a .docx file.
-
styleMap
: the style map to embed. -
Returns a promise.
CalltoBuffer()
on the value inside the promise to get aBuffer
representing the new document.
For instance:
mammoth.embedStyleMap({path: sourcePath}, "p[style-name='Section Title'] => h1:fresh") .then(function(docx) { fs.writeFile(destinationPath, docx.toBuffer(), callback); });
Messages
Each message has the following properties:
-
type
: a string representing the type of the message, such as"warning"
or
"error"
-
message
: a string containing the actual message -
error
(optional): the thrown exception that caused this message, if any
Image converters
An image converter can be created by calling mammoth.images.imgElement(func)
.
This creates an <img>
element for each image in the original docx.
func
should be a function that has one argument image
.
This argument is the image element being converted,
and has the following properties:
-
read([encoding])
: read the image file with the specified encoding.
If no encoding is specified, aBuffer
is returned. -
contentType
: the content type of the image, such asimage/png
.
func
should return an object (or a promise of an object) of attributes for the <img>
element.
At a minimum, this should include the src
attribute.
If any alt text is found for the image,
this will be automatically added to the element’s attributes.
For instance, the following replicates the default image conversion:
mammoth.images.imgElement(function(image) { return image.read("base64").then(function(imageBuffer) { return { src: "data:" + image.contentType + ";base64," + imageBuffer }; }); })
mammoth.images.dataUri
is the default image converter.
Document transforms
The API for document transforms should be considered unstable,
and may change between any versions.
If you rely on this behaviour,
you should pin to a specific version of mammoth.js,
and test carefully before updating.
Mammoth allows a document to be transformed before it is converted.
For instance,
suppose that document has not been semantically marked up,
but you know that any centre-aligned paragraph should be a heading.
You can use the transformDocument
argument to modify the document appropriately:
function transformElement(element) { if (element.children) { var children = _.map(element.children, transformElement); element = {...element, children: children}; } if (element.type === "paragraph") { element = transformParagraph(element); } return element; } function transformParagraph(element) { if (element.alignment === "center" && !element.styleId) { return {...element, styleId: "Heading2"}; } else { return element; } } var options = { transformDocument: transformElement };
The return value of transformDocument
is used during HTML generation.
The above can be written more succinctly using the helper mammoth.transforms.paragraph
:
function transformParagraph(element) { if (element.alignment === "center" && !element.styleId) { return {...element, styleId: "Heading2"}; } else { return element; } } var options = { transformDocument: mammoth.transforms.paragraph(transformParagraph) };
Or if you want paragraphs that have been explicitly set to use monospace fonts to represent code:
const monospaceFonts = ["consolas", "courier", "courier new"]; function transformParagraph(paragraph) { var runs = mammoth.transforms.getDescendantsOfType(paragraph, "run"); var isMatch = runs.length > 0 && runs.every(function(run) { return run.font && monospaceFonts.indexOf(run.font.toLowerCase()) !== -1; }); if (isMatch) { return { ...paragraph, styleId: "code", styleName: "Code" }; } else { return paragraph; } } var options = { transformDocument: mammoth.transforms.paragraph(transformParagraph), styleMap: [ "p[style-name='Code'] => pre:separator('n')" ] };
mammoth.transforms.paragraph(transformParagraph)
Returns a function that can be used as the transformDocument
option.
This will apply the function transformParagraph
to each paragraph element.
transformParagraph
should return the new paragraph.
mammoth.transforms.run(transformRun)
Returns a function that can be used as the transformDocument
option.
This will apply the function transformRun
to each run element.
transformRun
should return the new run.
mammoth.transforms.getDescendants(element)
Gets all descendants of an element.
mammoth.transforms.getDescendantsOfType(element, type)
Gets all descendants of a particular type of an element.
For instance, to get all runs within an element paragraph
:
var runs = mammoth.transforms.getDescendantsOfType(paragraph, "run");
Writing style maps
A style map is made up of a number of style mappings separated by new lines.
Blank lines and lines starting with #
are ignored.
A style mapping has two parts:
- On the left, before the arrow, is the document element matcher.
- On the right, after the arrow, is the HTML path.
When converting each paragraph,
Mammoth finds the first style mapping where the document element matcher matches the current paragraph.
Mammoth then ensures the HTML path is satisfied.
Freshness
When writing style mappings, it’s helpful to understand Mammoth’s notion of freshness.
When generating, Mammoth will only close an HTML element when necessary.
Otherwise, elements are reused.
For instance, suppose one of the specified style mappings is p[style-name='Heading 1'] => h1
.
If Mammoth encounters a .docx paragraph with the style name Heading 1
,
the .docx paragraph is converted to a h1
element with the same text.
If the next .docx paragraph also has the style name Heading 1
,
then the text of that paragraph will be appended to the existing h1
element,
rather than creating a new h1
element.
In most cases, you’ll probably want to generate a new h1
element instead.
You can specify this by using the :fresh
modifier:
p[style-name='Heading 1'] => h1:fresh
The two consecutive Heading 1
.docx paragraphs will then be converted to two separate h1
elements.
Reusing elements is useful in generating more complicated HTML structures.
For instance, suppose your .docx contains asides.
Each aside might have a heading and some body text,
which should be contained within a single div.aside
element.
In this case, style mappings similar to p[style-name='Aside Heading'] => div.aside > h2:fresh
and
p[style-name='Aside Text'] => div.aside > p:fresh
might be helpful.
Document element matchers
Paragraphs, runs and tables
Match any paragraph:
Match any run:
Match any table:
To match a paragraph, run or table with a specific style,
you can reference the style by name.
This is the style name that is displayed in Microsoft Word or LibreOffice.
For instance, to match a paragraph with the style name Heading 1
:
p[style-name='Heading 1']
You can also match a style name by prefix.
For instance, to match a paragraph where the style name starts with Heading
:
Styles can also be referenced by style ID.
This is the ID used internally in the .docx file.
To match a paragraph or run with a specific style ID,
append a dot followed by the style ID.
For instance, to match a paragraph with the style ID Heading1
:
Bold
Match explicitly bold text:
Note that this matches text that has had bold explicitly applied to it.
It will not match any text that is bold because of its paragraph or run style.
Italic
Match explicitly italic text:
Note that this matches text that has had italic explicitly applied to it.
It will not match any text that is italic because of its paragraph or run style.
Underline
Match explicitly underlined text:
Note that this matches text that has had underline explicitly applied to it.
It will not match any text that is underlined because of its paragraph or run style.
Strikethough
Match explicitly struckthrough text:
Note that this matches text that has had strikethrough explicitly applied to it.
It will not match any text that is struckthrough because of its paragraph or run style.
All caps
Match explicitly all caps text:
Note that this matches text that has had all caps explicitly applied to it.
It will not match any text that is all caps because of its paragraph or run style.
Small caps
Match explicitly small caps text:
Note that this matches text that has had small caps explicitly applied to it.
It will not match any text that is small caps because of its paragraph or run style.
Ignoring document elements
Use !
to ignore a document element.
For instance, to ignore any paragraph with the style Comment
:
p[style-name='Comment'] => !
HTML paths
Single elements
The simplest HTML path is to specify a single element.
For instance, to specify an h1
element:
To give an element a CSS class,
append a dot followed by the name of the class:
To require that an element is fresh, use :fresh
:
Modifiers must be used in the correct order:
Separators
To specify a separator to place between the contents of paragraphs that are collapsed together,
use :separator('SEPARATOR STRING')
.
For instance, suppose a document contains a block of code where each line of code is a paragraph with the style Code Block
.
We can write a style mapping to map such paragraphs to <pre>
elements:
p[style-name='Code Block'] => pre
Since pre
isn’t marked as :fresh
,
consecutive pre
elements will be collapsed together.
However, this results in the code all being on one line.
We can use :separator
to insert a newline between each line of code:
p[style-name='Code Block'] => pre:separator('n')
Nested elements
Use >
to specify nested elements.
For instance, to specify h2
within div.aside
:
You can nest elements to any depth.
Upgrading to later versions
1.0.0
The convertUnderline
option is no longer supported.
Use style mappings to control how underlines are handled.
0.3.0
If you’ve defined custom style maps or used a document transform,
you will likely need to change your usage slightly.
Otherwise, you should be able to continue using Mammoth as before.
Custom style maps
Prior to 0.3.0, Mammoth matched docx paragraphs using style IDs e.g. p.Heading1
.
These IDs are used internally in the docx format,
and are distinct from the style name
i.e. the name shown by Microsoft Word or LibreOffice.
Although Mammoth still supports matching styles by ID,
matching styles by name is preferred.
For instance, instead of:
p.AsideHeading => h1
prefer:
p[style-name='Aside Heading'] => h1
Document transforms
Prior to 0.3.0,
Mammoth (misleadingly) assigned the style ID to a property called styleName
.
The style ID is now assigned to a more appropriate property, styleId
.
The styleName
property is now set to the name of the style.
To preserve existing behaviour,
any existing document transforms should be rewritten in one of two ways:
-
Set the
styleId
property instead of thestyleName
property -
Set the
styleName
property to the name of the style, rather than the ID
0.2.0
The function mammoth.style()
was renamed to mammoth.styleMapping()
.
Acknowledgements
Thanks to the following people for their contributions to Mammoth:
-
Craig Leinoff:
- Document transforms
-
John McLear:
- Underline support
-
Chris Price:
- node.js
Buffer
support - UTF8 BOM handling
- node.js
-
Stoo Goff
- Markdown support
-
Andreas Lubbe
- Internal hyperlink support
-
Jacob Wang
- Supporting styles defined without names
Donations
If you’d like to say thanks, feel free to make a donation through Ko-fi.
If you use Mammoth as part of your business,
please consider supporting the ongoing maintenance of Mammoth by making a weekly donation through Liberapay.
Use this free online tool to convert Microsoft Word documents to HTML code. It extracts all text content from a word doc into downloadable and clean HTML.
By default, it produces very tidy HTML code from a word doc. This clean HTML option is probably the best format option for most people. It produces classless elements in a clear, readable format.
However, there are a few things to note. The HTML code will have empty image src tags so you’ll have to reference your online images for those to work, and it’s generally not good with HTML lists.
Other than that, it works pretty well and is super handy if you’re looking to quickly convert content from a word doc into a usable HTML format.
Note: here’s the old version of Word to HTML if you need to use it.
Convert Word to HTML File Revisions
This free tool has been recently revised to use word document uploads instead of using a manual process like the old Word to HTML version of this converter.
With a click of a button, you can now automatically save the document conversion results as a downloadable HTML page. This tool makes it easy to instantly convert Word to HTML without having to paste the document.
The old version of this Word to HTML converter relied on copying and pasting the content from an open Word doc which was a clunkier process. This new version allows direct Word document uploads and outputs HTML files or copyable clean code making for a far better process.
I hope you enjoy this newly revised word to HTML tool. It really is much better now at converting Word documents.
Most Popular Text Tools
Alphabetical Tools
Random Generators
Line Break Tools
Fun Text Tools
Text Changing Tools
SEO and Word Tools
Content Conversion Tools
HTML Code Generators
HTML Compression
HTML Encoding Tools
Download Article
Save your .docx as an .html web page file
Download Article
- Using Microsoft Word
- Using Google Drive
- Using Word 2 Clean HTML
- Video
- Q&A
- Tips
|
|
|
|
|
If you have Microsoft Word on your computer, you can resave the DOC/DOCX file as an HTML file without installing additional software. If you don’t have Word or prefer a free online option, you can upload the document to Google Drive and save it as an HTML file. Or, paste the contents of the Word file into a converter like Word 2 Clean HTML. Since Word documents and HTML files are very different, the finished HTML webpage may not contain the same formatting as the original. This wikiHow will show you how to convert a Word document to HTML on your Windows PC or Mac.
Things You Should Know
- In Microsoft Word, go to File > Save As. Change the file type to Web Page.
- For Google Drive, upload and open the Word file in Google Docs. Then, go to File > Download > Web Page.
- Try an HTML conversion web app like Word 2 Clean HTML for additional automatic formatting options.
-
1
Open the document in Microsoft Word. Word has a built-in feature to convert .docx documents to HTML files. Although the resulting HTML code may be a bit bulkier than if you’d written the HTML from scratch, the conversion is quick and can be used for simpler projects.[1]
- If you’re looking for general HTML tips, check out how to create a simple web page, create a link, and make radio buttons.
-
2
Click the File menu. It’s at the top-left corner of Word.
Advertisement
-
3
Click Save As. A list of locations will appear.
-
4
Select a location. You can save the file to any folder on your computer (or a cloud drive).
-
5
Type a name for the file. Enter the name in the textbox next to “File name:”.
-
6
Select Web Page from the «Save as type» dropdown menu. This will save the file in HTML format.
- If you’re okay with losing some of the advanced layout code in favor of a simpler file, select Web Page, Filtered instead. This keeps only the style instructions, content, and some other info.
-
7
Click Save. A new version of the file is now saved in the HTML format.
Advertisement
-
1
Go to https://www.google.com/drive in a web browser. Then click Go to Drive. As long as you have a Google account, you can use Google Drive to convert a Word document to a web page.
-
2
Click the + New button. It’s at the top-left corner of Google Drive.
-
3
Click File upload. It’s the second option.
-
4
Select your Word document and click Open. This uploads the Word document to your Google Drive.
-
5
Right-click the Word document in Google Drive. A pop-up context menu will open.
-
6
Click Open with. Another menu will expand.
-
7
Click Google Docs. The contents of your Word document will display in Google Docs.
-
8
Click the File menu in Google Docs. It’s just below the file name at the top-left corner of the document.
-
9
Click Download. Additional menu options will appear.
-
10
Click Web Page. This allows you to save the .docx as an HTML zipped file. If prompted to do so, click Save or OK to start the download.
Advertisement
-
1
Go to https://word2cleanhtml.com in a web browser. Word 2 Clean HTML is a free, easy-to-use tool that will take the contents of a Word document and convert it to HTML code.
-
2
Open the Word document you want to convert. If you have Microsoft Word, open the document in that application. If not, you can either use the free version of Word located at https://www.office.com to open the file, or a Word alternative like Google Drive.
-
3
Copy the contents of the Word file to the clipboard. Press the Control and A keys (PC) or Command and A keys (Mac) at the same time to highlight everything in the file, right-click the highlighted area, and then click Copy.
-
4
Paste the copied text into the Word to Clean HTML field. Right-click the typing area and select Paste to paste the selected content.
-
5
Adjust your HTML preferences below the form. Use the checkboxes at the bottom of the page to toggle conversion preferences, such as converting Word’s Smart Quotes to regular ASCII quotes.
-
6
Click the convert to clean html button. It’s the button below the form. This converts the content to the HTML format and displays it in the text area.
- To see the regular HTML (not «cleaned up») from the conversion, click the Original HTML tab.
- To see a preview of how the code would look in a web browser, click the Preview tab.
- To copy the code so you can paste it elsewhere, click the Copy cleaned HTML to clipboard link at the top of the page.
Advertisement
Add New Question
-
Question
What do I do if I did this accidentally and really want to delete it now?
If you want to delete it, right-click on it and click delete. If you want to change it back, rename the file extension from randomfile.html to randomfile.docx.
-
Question
I want to convert a Word document with controls (text box) to an HTML file, which has those controls. How do I do this?
Change the ending from whatever it is (ex: .txt) to .html (ex: .html).
-
Question
If I save a Word document as a web page using HTML, will it have an URL?
Yes it will because you are basically making a website and all websites have a URL.
See more answers
Ask a Question
200 characters left
Include your email address to get a message when this question is answered.
Submit
Advertisement
-
If you have to convert hundreds of files to HTML, use commercial software that can convert them all at once. Some options are Doc Converter Pro (formerly Word Cleaner) and NCH Doxillion.
-
It is not always possible to keep all of your Word formatting and styles during the conversion, and still have the HTML file display consistently on all browsers. You might need to use CSS to achieve this on your website.
-
Looking for money-saving deals on Microsoft Office products? Check out our coupon site for tons of coupons and promo codes on your next subscription.
Thanks for submitting a tip for review!
Advertisement
References
About This Article
Article SummaryX
«To use Microsoft Word to convert a Word document to HTML, start by opening the document in Word. Click the File menu and choose Save as. Choose where you want to save the file, and then give it a name. Click the «»Save as type»» menu and select Web Page. Click Save to save your new HTML code to the desired location.
To use Google Drive, start by signing in to Google Drive in a web browser. Click the New button and select File upload. Select the Word document and click Open to add it to your Drive. Once the upload is complete, right-click the document in drive, select Open with, and then select Google Docs. When you see the document, click the File menu, select Download, and choose the Web Page option. This downloads a ZIP file of your new HTML to your computer.
»
Did this summary help you?
Thanks to all authors for creating a page that has been read 768,550 times.
Is this article up to date?
Free online Text/Word to HTML converter with built-in code cleaning features with escapes or unescapes HTML tags.
Hypertext Markup Language (HTML) is the standard markup language for creating web pages and web applications. Web browsers receive HTML documents from a web server or from local storage and render the documents into multimedia web pages. HTML describes the structure of a web page semantically and originally included cues for the appearance of the document.
HTML elements are the building blocks of HTML pages. With HTML constructs, images and other objects such as interactive forms may be embedded into the rendered page. HTML provides a means to create structured documents by denoting structural semantics for text such as headings, paragraphs, lists, links, quotes and other items. HTML elements are delineated by tags, written using angle brackets. Tags such as <img/> and <input/> directly introduce content into the page. Other tags such as <p> surround and provide information about document text and may include other tags as sub-elements. Browsers do not display the HTML tags, but use them to interpret the content of the page.
Escapes or unescapes an HTML
Convert special characters to HTML entities. Certain characters have special significance in HTML, and should be represented by HTML entities if they are to preserve their meanings. This function returns a string with these conversions made.
The following characters are reserved in HTML and must be replaced with their corresponding HTML entities:
The translations performed are:
- ‘&’ (ampersand) becomes ‘&’
- ‘»‘ (double quote) becomes ‘"’
- «‘» (single quote) becomes ‘'’
- ‘<‘ (less than) becomes ‘<’
- ‘>’ (greater than) becomes ‘>’
What Is HTML? Hypertext Markup Language Basics Explained
HTML stands for HyperText Markup Language. HTML is the primary markup language found on the internet. Every HTML page has a series of elements that create the content structure of a web page or application. HTML provides the structure and content of a web page, and it is used in conjunction with other technologies like CSS and JavaScript to make websites dynamic and interactive.
HTML consists of a series of elements and tags, which are used to define the structure and content of a web page. For example, the title of a web page is typically defined using an <h1> tag, and paragraphs of text are defined using the <p> tag. HTML also includes tags for creating lists, links, images, tables, and many other types of content.
The three main parts of an element are:
- Opening tag – used to state where an element starts to take effect. The tag is wrapped with opening and closing angle brackets. For example, use the start tag
to create a paragraph.
- Content – this is the output that other users see.
- Closing tag – the same as the opening tag, but with a forward slash before the element name. For example, </p> to end a paragraph.
The combination of these three parts will create an HTML element:
<p> This is how you add a paragraph in HTML.</p>
Every HTML page uses these three tags:
- <html> tag is the root element that defines the whole HTML document.
- <head> tag holds meta information such as the page’s title and charset.
- <body> tag encloses all the content that appears on the page.
<html> <head> <!-- META INFORMATION --> </head> <body> <!-- PAGE CONTENT --> </body></html>
Other popular block-level tags include:
- Heading tags – these range from <h1> to <h6>, where heading h1 is largest in size, getting smaller as they move up to h6.
- Paragraph tags – are all enclosed by using the <p> tag.
- List tags – have different variations. Use the tag for an ordered list, and use for an unordered list. Then, enclose individual list items using the <li> tag.
HTML has evolved over the years, with new versions being introduced to add new capabilities and improve the language. The latest version of HTML is HTML5, which provides new elements and attributes, improved semantic elements, and better support for multimedia and other types of web-based content.
How To Use This Online WORD/Text to HTML Generator Tool?
The WORD/Text to HTML Generator we offer is user-friendly and provides a seamless experience for both professionals and beginners. No complex rules or technical know-how is required to utilize this service, making it accessible for everyone. The straightforward steps outlined below will assist you in using our tool to view HTML Code code online.
- Type or Paste your content in the input box provided on this tool. The tool allows its users to copy-paste code.
- The next step is to click the «Convert to HTML» button as per your requirement.
- As this button is pressed, the results are generated and displayed instantaneously.
- Use «HTML Escape» and «Unescape HTML» options to convert your output.
- After you have generated the HTML code, you can click on «Copy to Clipboard» or select all converted text and press «Control-C» to copy, and then «Control-V» to paste it back into your document.
- Alternatively, you can download generated HTML code to a text file by simply clicking on the «Download» button.
Useful Features of Our Online WORD/Text to HTML Generator
The Online WORD/Text to HTML Generator tool on our website comes equipped with exceptional features, making it the best online tool for generate text or HTML codes. The most notable features of our online utility are listed below.
Free and Simple to Use
The use of this tool comes at no cost, and it’s effortless to use. With the simple set of instructions provided, you’ll be able to view and run codes easily.
View and Verify HTML
You can now quickly view the output of any HTML code and test its validity with just one click.
Compatibility
This tool is a cloud-based utility and supported by all operating systems, including iOS, Android, Windows, and Mac OS, allowing you to access and use it for viewing HTML files from any device.
No Plugin Installation Needed
You can access this tool through the web browser of your device without having to install any plugins. This HTML viewer operates without the need for any plugins, making it convenient to use.
Speedy and Secure
The tool displays results on the user’s screen in mere seconds, and it’s a secure online utility that doesn’t save any data entered or uploaded by users in its databases.
Accessible from Everywhere
You can access our tool from anywhere in the world as long as you have an internet connection. Simply connect your device to the internet, and you’ll be able to use and access this code viewer.
Privacy of Users’ Data
At Onlinewebtoolkit, we offer a variety of online tools, including an WORD/Text to HTML Generator, and we take the privacy of our users’ data very seriously. With so many online scams, many people are concerned about their sensitive information being compromised when using online tools. However, our website provides a secure and safe tool that prevents hackers from accessing or intentionally sharing users’ information with third parties. The HTML code you input into our tool is only stored temporarily on the client side within your browser until the formatting process is complete. Once the results are displayed or you refresh or close the browser, your data is deleted from our site.