How to Generate Markdown from JSON Output in Azure Document Intelligence

Nelson Guamán 40 Reputation points
2025-04-06T14:47:05.9233333+00:00

Hello, good afternoon.

I’m using Azure Document Intelligence with the layout model in Python, using the option to get the result in Markdown format, and it works correctly.

poller = self.client.begin_analyze_document(
    "prebuilt-layout",
    AnalyzeDocumentRequest(bytes_source=file_content),
    output_content_format=DocumentContentFormat.MARKDOWN,
    output=[AnalyzeOutputOption.FIGURES],
)

However, I’ve run into an issue: I need to access the information included in the JSON response (such as the polygon, span, and other attributes), but when I check the content variable, the content is returned as plain text rather than Markdown.

Is there a way to generate the Markdown from the JSON? Would you consider including a function in the library to transform the JSON into Markdown? I’d like to avoid making two separate calls to the same PDF.

Thank you very much.

Azure AI Document Intelligence
Azure AI Document Intelligence
An Azure service that turns documents into usable data. Previously known as Azure Form Recognizer.
2,100 questions
0 comments No comments
{count} votes

Accepted answer
  1. Pavankumar Purilla 8,335 Reputation points Microsoft External Staff Moderator
    2025-04-07T03:37:13.3+00:00

    Hi Nelson Guamán,

    I'm glad that you were able to resolve your issue and thank you for posting your solution so that others experiencing the same thing can easily reference this!

    Since the Microsoft Q&A community has a policy that "The question author cannot accept their own answer. They can only accept answers by others", I'll repost your solution.

    Please click "Accept" the answer as original posters help the community find answers faster by identifying the correct answer.

    Issue : How to Generate Markdown from JSON Output in Azure Document Intelligence

    Resolution : It was simply a matter of doing the following:

    poller = self.client.begin_analyze_document( "prebuilt-layout", AnalyzeDocumentRequest(bytes_source=file_content), output_content_format=DocumentContentFormat.MARKDOWN, 
    output=[AnalyzeOutputOption.FIGURES], ) 
    analyze_result: AnalyzeResult = poller.result() 
    print(analyze_result.as_dict())
    

    Please don’t forget to close the thread by clicking "Accept the answer" wherever the information provided helps you, as this can be beneficial to other community members.

    Accept answers on Microsoft Q&A | Microsoft Learn

    An accepted answer is the answer that the person who asked the question chooses as the one they think best solves their problem.

    1 person found this answer helpful.
    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Nelson Guamán 40 Reputation points
    2025-04-06T14:55:25.16+00:00

    My mistake.

    It was simply a matter of doing the following:

    poller = self.client.begin_analyze_document(
        "prebuilt-layout",
        AnalyzeDocumentRequest(bytes_source=file_content),
        output_content_format=DocumentContentFormat.MARKDOWN,
        output=[AnalyzeOutputOption.FIGURES],
    )
    
    analyze_result: AnalyzeResult = poller.result()
    
    print(analyze_result.as_dict())
    

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.