Skip to main content
Known Participant
Mar 17, 2023 10:19 AM UTC
Question

Convert idml file into HTML

Hello everyone,

Im currently working to convert the idml file into html and try to fix this via automation. And tried with some extendscript code

Main();

function Main() {
	// Check to see whether any InDesign documents are open.
	// If no documents are open, display an error message.
	if (app.documents.length > 0) {
		var myDoc = app.activeDocument;
		// Build the filename
		var myDocName = decodeURI(myDoc.fullName);
		var myDocBaseName = myDocName.substring(0, myDocName.lastIndexOf(".")); 
		// Export the page to FXL HTML
		with (myDoc.htmlFXLExportPreferences) {
			// HTMLRangeFormat = PageRangeFormat.EXPORT_ALL_PAGES
			HTMLRangeFormat = PageRangeFormat.EXPORT_PAGE_RANGE
			// HTMLPageRange = "1-2";
		}
		myDoc.exportFile(ExportFormat.HTMLFXL, new File(myDocBaseName + ".html"), true);
	}
	else {
		// No documents are open, so display an error message.
		alert("No InDesign documents are open. Please open a document and try again.")
	}
}

My requirement is to convert the idml file into HTML without formating and it has run in the background means which is helpful, some of the users haven't Indesign Application.
I have checked with different  languages ie., NodeJS, python, C# and not get any solution. Please anyone done this before share your idealogy and apporoach to proceed further.

Thanks


12 replies

Moskito_89
Participant
Oct 14, 2026 7:23 AM UTC

Hi ​@Rocky@, ​

I know I’m a bit late, but you might still find this interesting: I’ve developed a library that converts IDML and even INDD files into HTML and CSS. It runs in PHP and aims to reproduce the layout as accurately as possible. So it’s not about extracting text in a semantically correct way, as some other libraries do, but about mimicking the layout structure. If you’re interested, you can find more information at https://www.idml.dev/en/html-to-idml-converter-php.html 

I should mention that the library isn’t freely available – but please do let me know if you’d like me to carry out a few test conversions for you. 

Best regards!

Translate
Participant
Feb 20, 2025 8:19 PM UTC

There is indeed a script to convert IDML file to HTML / text. You can do it with a python script that I developed. It uses SimpleIDML library and aims at extracting text content in correct order, while also creating a list of images assiciated with your IDML file. Please, refer to github repo: idml2html-python  .

 

The script is intended for batch processing and goes with a bash script that first looks for IDML files and extracts them, and creates list of files that is fed to the py script.

 

There is also an online javascript app which convert IDML into html / text.  It is here: https://textvisualization.app/idml2html/ You can use it to view text content of an IDML file if you do not have inDesign. Surely, you can use it as a converter and extractor of text and image links.  

 

Translate
Participant
Feb 20, 2025 8:22 PM UTC

The script to convert IDML to HTML / text is here: https://github.com/roverbird/idml2html-python

Translate
Community Expert
Mar 19, 2023 4:46 AM UTC

Hi @Rocky@,

IDML is an open format so you need to read/understand the format specification and then do the translation to HTML as desired. Since IDML is just a bunch of XML files you could use any laguage like JS, Python etc to parse those XML files get the information relevant to you and then write the logic to use that information to create HTML files. It is a tedious process but not that complex.

-Manan

Translate
-Manan
Rocky@Author
Known Participant
Mar 19, 2023 7:07 AM UTC

Is it possible to convert with out Indesign application?

Translate
Community Expert
Mar 19, 2023 7:15 AM UTC

Yes absolutely, as I said IDML is a bunch of XML files. Read the specification so that you know where to look for which information, then parse the files, get the information you need and create HTML accordingly.

-Manan

Translate
-Manan