LangChain/Prompts & Output
Intermediate7 min

Output Parsers

StrOutputParser is the everyday default. JsonOutputParser is the fallback for streaming JSON or models without tool calling. PydanticOutputParser is legacy — use with_structured_output() instead.

Quick Reference

  • StrOutputParser extracts .content as a plain string — use this for all text chains
  • JsonOutputParser is the only parser still worth using — specifically for streaming partial JSON
  • PydanticOutputParser is deprecated — use with_structured_output() instead
  • All parsers are Runnables — compose them with | in LCEL chains

Deprecation Notice

Output parsers are legacy in LangChain v1

In LangChain v1, structured output is handled by ProviderStrategy and ToolStrategy via create_agent's response_format parameter or model.with_structured_output(). Output parsers remain available in langchain-classic for backward compatibility, but new code should use structured output strategies instead. The only parser still worth using is JsonOutputParser for streaming partial JSON from models without tool calling support.