LangChain Reference home pageLangChain ReferenceLangChain Reference
  • GitHub
  • Main Docs
Deep Agents
LangChain
LangGraph
Integrations
LangSmith
  • Overview
    • Overview
    • Caches
    • Callbacks
    • Documents
    • Document loaders
    • Embeddings
    • Exceptions
    • Language models
    • Serialization
    • Output parsers
    • Prompts
    • Rate limiters
    • Retrievers
    • Runnables
    • Utilities
    • Vector stores
    MCP Adapters
    Standard Tests
    Text Splitters
    ⌘I

    LangChain Assistant

    Ask a question to get started

    Enter to send•Shift+Enter new line

    Menu

    OverviewCachesCallbacksDocumentsDocument loadersEmbeddingsExceptionsLanguage modelsSerializationOutput parsersPromptsRate limitersRetrieversRunnablesUtilitiesVector stores
    MCP Adapters
    Standard Tests
    Text Splitters
    Language
    Theme
    Pythonlangchain-coreoutput_parsers
    Module●Since v0.1

    output_parsers

    OutputParser classes parse the output of an LLM call into structured data.

    Structured output

    Output parsers emerged as an early solution to the challenge of obtaining structured output from LLMs.

    Today, most LLMs support structured output natively. In such cases, using output parsers may be unnecessary, and you should leverage the model's built-in capabilities for structured output. Refer to the documentation of your chosen model for guidance on how to achieve structured output directly.

    Output parsers remain valuable when working with models that do not support structured output natively, or when you require additional processing or validation of the model's output beyond its inherent capabilities.

    Attributes

    attribute
    SimpleJsonOutputParser: JsonOutputParser

    Functions

    function
    import_attr

    Import an attribute from a module located in a package.

    This utility function is used in custom __getattr__ methods within __init__.py files to dynamically import attributes.

    Classes

    class
    BaseGenerationOutputParser

    Base class to parse the output of an LLM call.

    class
    BaseLLMOutputParser

    Abstract base class for parsing the outputs of a model.

    class
    BaseOutputParser

    Base class to parse the output of an LLM call.

    Output parsers help structure language model responses.

    class
    JsonOutputParser

    Parse the output of an LLM call to a JSON object.

    Probably the most reliable output parser for getting structured data that does not use function calling.

    When used in streaming mode, it will yield partial JSON objects containing all the keys that have been returned so far.

    In streaming, if diff is set to True, yields JSONPatch operations describing the difference between the previous and the current object.

    class
    CommaSeparatedListOutputParser

    Parse the output of a model to a comma-separated list.

    class
    ListOutputParser

    Parse the output of a model to a list.

    class
    MarkdownListOutputParser

    Parse a Markdown list.

    class
    NumberedListOutputParser

    Parse a numbered list.

    class
    JsonOutputKeyToolsParser

    Parse tools from OpenAI response.

    class
    JsonOutputToolsParser

    Parse tools from OpenAI response.

    class
    PydanticToolsParser

    Parse tools from OpenAI response.

    class
    PydanticOutputParser

    Parse an output using a Pydantic model.

    class
    StrOutputParser

    Extract text content from model outputs as a string.

    Converts model outputs (such as AIMessage or AIMessageChunk objects) into plain text strings. It's the simplest output parser and is useful when you need string responses for downstream processing, display, or storage.

    Supports streaming, yielding text chunks as they're generated by the model.

    class
    BaseCumulativeTransformOutputParser

    Base class for an output parser that can handle streaming input.

    class
    BaseTransformOutputParser

    Base class for an output parser that can handle streaming input.

    class
    XMLOutputParser

    Parse an output using xml format.

    Returns a dictionary of tags.

    Modules

    module
    list

    Parsers for list output.

    module
    transform

    Base classes for output parsers that can handle streaming input.

    module
    format_instructions

    Format instructions.

    module
    string

    String output parser.

    module
    openai_functions

    Parsers for OpenAI functions output.

    module
    pydantic

    Output parsers using Pydantic.

    module
    openai_tools

    Parse tools for OpenAI tools output.

    module
    json

    Parser for JSON output.

    module
    xml

    Output parser for XML format.

    module
    base

    Base parser for language model outputs.

    View source on GitHub