Skip to main contentü¶úÔ∏èüîó LangChainDocsUse casesIntegrationsAPICommunityChat our docsLangSmithJS/TS DocsSearchCTRLKGet startedIntroductionInstallationQuickstartLangChain Expression LanguageInterfaceHow toCookbookLangChain Expression Language (LCEL)Why use LCEL?ModulesModel I/‚ÄãORetrievalDocument loadersDocument transformersText splittersHTMLHeaderTextSplitterSplit by characterSplit codeMarkdownHeaderTextSplitterRecursively split by characterSplit by tokensPost retrievalText embedding modelsVector storesRetrieversIndexingChainsMemoryAgentsCallbacksModulesSecurityGuidesMoreModulesRetrievalDocument transformersText splittersSplit codeOn this pageSplit codeCodeTextSplitter allows you to split your code with multiple languages supported. Import enum Language and specify the language. from langchain.text_splitter import (    RecursiveCharacterTextSplitter,    Language,)# Full list of support languages[e.value for e in Language]    ['cpp',     'go',     'java',     'kotlin',     'js',     'ts',     'php',     'proto',     'python',     'rst',     'ruby',     'rust',     'scala',     'swift',     'markdown',     'latex',     'html',     'sol',     'csharp']# You can also see the separators used for a given languageRecursiveCharacterTextSplitter.get_separators_for_language(Language.PYTHON)    ['\nclass ', '\ndef ', '\n\tdef ', '\n\n', '\n', ' ', '']Python‚ÄãHere's an example using the PythonTextSplitter:PYTHON_CODE = """def hello_world():    print("Hello, World!")# Call the functionhello_world()"""python_splitter = RecursiveCharacterTextSplitter.from_language(    language=Language.PYTHON, chunk_size=50, chunk_overlap=0)python_docs = python_splitter.create_documents([PYTHON_CODE])python_docs    [Document(page_content='def hello_world():\n    print("Hello, World!")', metadata={}),     Document(page_content='# Call the function\nhello_world()', metadata={})]JS‚ÄãHere's an example using the JS text splitter:JS_CODE = """function helloWorld() {  console.log("Hello,
CodeTextSplitter allows you to split your code with multiple languages supported. Import enum Language and specify the language.
CodeTextSplitter allows you to split your code with multiple languages supported. Import enum Language and specify the language. ->: Skip to main contentü¶úÔ∏èüîó LangChainDocsUse casesIntegrationsAPICommunityChat our docsLangSmithJS/TS DocsSearchCTRLKGet startedIntroductionInstallationQuickstartLangChain Expression LanguageInterfaceHow toCookbookLangChain Expression Language (LCEL)Why use LCEL?ModulesModel I/‚ÄãORetrievalDocument loadersDocument transformersText splittersHTMLHeaderTextSplitterSplit by characterSplit codeMarkdownHeaderTextSplitterRecursively split by characterSplit by tokensPost retrievalText embedding modelsVector storesRetrieversIndexingChainsMemoryAgentsCallbacksModulesSecurityGuidesMoreModulesRetrievalDocument transformersText splittersSplit codeOn this pageSplit codeCodeTextSplitter allows you to split your code with multiple languages supported. Import enum Language and specify the language. from langchain.text_splitter import (    RecursiveCharacterTextSplitter,    Language,)# Full list of support languages[e.value for e in Language]    ['cpp',     'go',     'java',     'kotlin',     'js',     'ts',     'php',     'proto',     'python',     'rst',     'ruby',     'rust',     'scala',     'swift',     'markdown',     'latex',     'html',     'sol',     'csharp']# You can also see the separators used for a given languageRecursiveCharacterTextSplitter.get_separators_for_language(Language.PYTHON)    ['\nclass ', '\ndef ', '\n\tdef ', '\n\n', '\n', ' ', '']Python‚ÄãHere's an example using the PythonTextSplitter:PYTHON_CODE = """def hello_world():    print("Hello, World!")# Call the functionhello_world()"""python_splitter = RecursiveCharacterTextSplitter.from_language(    language=Language.PYTHON, chunk_size=50, chunk_overlap=0)python_docs = python_splitter.create_documents([PYTHON_CODE])python_docs    [Document(page_content='def hello_world():\n    print("Hello, World!")', metadata={}),     Document(page_content='# Call the function\nhello_world()', metadata={})]JS‚ÄãHere's an example using the JS text splitter:JS_CODE = """function helloWorld() {  console.log("Hello,