# Which Chat Formats Does the MemPalace Normalize Module Support?

> Explore MemPalace normalize module's support for seven chat formats including Claude OpenAI Gemini Slack and plain text. Auto-detects formats for seamless integration.

- Repository: [MemPalace/mempalace](https://github.com/MemPalace/mempalace)
- Tags: api-reference
- Published: 2026-06-06

---

**The `mempalace.normalize` module supports seven distinct input formats: Claude code‑JSONL, Claude AI JSON, OpenAI ChatGPT JSON, Codex JSONL, Gemini JSONL, Slack JSON, and plain‑text transcripts, automatically detecting each via private `_try_*` helper functions.**

The `mempalace.normalize` module serves as the ingestion layer for the MemPalace project, converting raw chat exports from various AI assistants and messaging platforms into clean, canonical text suitable for indexing. Located in [`mempalace/normalize.py`](https://github.com/MemPalace/mempalace/blob/main/mempalace/normalize.py), this module eliminates manual format conversion by automatically identifying and parsing structured JSON and JSONL exports without requiring explicit format declarations from the user.

## Supported Chat Formats

The module recognizes six structured export formats plus a plain‑text fallback. Each format is handled by a dedicated private parser function defined in [`mempalace/normalize.py`](https://github.com/MemPalace/mempalace/blob/main/mempalace/normalize.py).

### Claude Export Formats

- **Claude code‑JSONL**: Detected by **`_try_claude_code_jsonl()`**, this parser handles JSONL files where each line contains a Claude message object, typically exported from the Claude code interface.

- **Claude AI JSON**: Processed by **`_try_claude_ai_json()`**, which parses nested JSON objects containing a `messages` list generated by the standard Claude AI UI.

### OpenAI and Google Formats

- **OpenAI ChatGPT JSON**: Handled by **`_try_chatgpt_json()`**, this parser interprets the standard OpenAI chat‑completion schema featuring `messages` arrays with `role` and `content` fields.

- **Gemini JSONL**: Managed by **`_try_gemini_jsonl()`** for Google Gemini Chat exports, processing JSONL streams where each line represents a Gemini message object.

### Developer Tool Exports

- **Codex JSONL**: Processed via **`_try_codex_jsonl()`**, specifically designed for JSONL logs produced by the Codex code‑completion tool during IDE sessions.

### Collaboration Platforms

- **Slack JSON**: Parsed by **`_try_slack_json()`**, interpreting exported Slack conversation archives containing `messages` arrays with `text` fields and optional `blocks` structures.

### Plain‑Text Fallback

When no structured parser matches the input, the module falls back to **`strip_noise()`**, which returns the original content after removing system‑generated artifacts. This ensures that free‑form transcripts, copy‑pasted chat windows, or unsupported formats remain usable for indexing.

## Detection Strategy in normalize.py

The **`normalize(filepath)`** function acts as the primary entry point. According to the implementation in [`mempalace/normalize.py`](https://github.com/MemPalace/mempalace/blob/main/mempalace/normalize.py), it attempts each private `_try_*` helper in sequence until one successfully extracts content. The first parser to return a valid string wins; if all structured parsers fail, the raw file content passes through `strip_noise()` unchanged.

The conceptual execution flow follows this pattern:

```python

# Conceptual implementation based on mempalace/normalize.py

def normalize(filepath):
    content = read_file(filepath)
    
    # Ordered attempts by format specificity

    for parser in [
        _try_claude_code_jsonl,
        _try_claude_ai_json,
        _try_chatgpt_json,
        _try_codex_jsonl,
        _try_gemini_jsonl,
        _try_slack_json
    ]:
        result = parser(content)
        if result:
            return result
            
    return strip_noise(content)

```

This cascade approach allows MemPalace to ingest diverse chat sources without requiring users to specify the export type manually.

## Test Coverage

Each format detection path is exercised in **[`tests/test_normalize.py`](https://github.com/MemPalace/mempalace/blob/main/tests/test_normalize.py)**, which validates that the parsers correctly identify file types, handle malformed JSON gracefully, and produce expected plain‑text output. The test suite covers nested message structures, multi‑line JSONL entries, and Slack’s block‑formatted attachments.

## Summary

- **Seven formats supported**: Claude code‑JSONL, Claude AI JSON, OpenAI ChatGPT JSON, Codex JSONL, Gemini JSONL, Slack JSON, and plain‑text transcripts
- **Detection mechanism**: Private `_try_*` helpers in [`mempalace/normalize.py`](https://github.com/MemPalace/mempalace/blob/main/mempalace/normalize.py) attempt parsing in sequence
- **Entry point**: The `normalize()` function accepts a file path and returns canonical text
- **Fallback behavior**: `strip_noise()` handles unrecognized formats by cleaning raw text
- **Validation**: Complete test coverage exists in [`tests/test_normalize.py`](https://github.com/MemPalace/mempalace/blob/main/tests/test_normalize.py)

## Frequently Asked Questions

### How does the normalize module decide which parser to use?

The module runs a series of private helper functions—`_try_claude_code_jsonl()`, `_try_chatgpt_json()`, and others—in a fixed sequence. The first parser that successfully extracts content from the file returns the result immediately, short‑circuiting subsequent checks.

### What happens if my chat export format is not listed?

If none of the six structured parsers match, the module passes the raw file content to `strip_noise()`, which removes system artifacts and returns the cleaned text. The transcript remains indexed, though structured metadata like speaker labels may not be parsed.

### Can I use the normalize module on files outside of MemPalace?

Yes. The `normalize()` function in [`mempalace/normalize.py`](https://github.com/MemPalace/mempalace/blob/main/mempalace/normalize.py) accepts any file path and returns a string, making it suitable for standalone scripts or preprocessing pipelines that require normalized chat text.

### Where are the format detection tests located?

All format detection logic is validated in [`tests/test_normalize.py`](https://github.com/MemPalace/mempalace/blob/main/tests/test_normalize.py), which includes dedicated test cases for each supported export type, ensuring the correct `_try_*` helper is invoked and that output matches expected canonical text.