npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

kakaotalk-chat-parser

v0.1.1

Published

카카오톡 대화 내보내기 파일(.txt) 파서 / Parse KakaoTalk chat export files

Readme

kakaotalk-chat-parser

카카오톡 대화 내보내기 파일(.txt)을 파싱하는 TypeScript 라이브러리입니다. 플랫폼·런타임 의존성이 없어 브라우저, Node.js, Electron 등 어디서든 동작합니다.

지원되지 않는 포맷을 발견하면 이슈로 남겨주세요.

지원 포맷

카카오톡은 내보내기 포맷이 여러 번 바뀌었습니다. 각 유형의 샘플과 특징은 다음과 같습니다.

시간 먼저 (Time First)

오후 10:50, 2011년 11월 6일
오후 10:50, 2011년 11월 6일, 홍길동 : 안녕하세요
오후 10:51, 2011년 11월 6일, 김철수 : 반갑습니다
  • 날짜 구분선과 메시지의 날짜/시간 형식이 동일합니다.

날짜 먼저 (Date First)

2014년 1월 16일 오전 3:23
2014년 1월 16일 오전 3:23, 홍길동 : 안녕하세요
2014년 1월 16일 오전 3:24, 김철수 : 반갑습니다
  • 날짜 구분선과 메시지의 날짜/시간 형식이 동일합니다.

점 구분 날짜 (Dot Date)

2021년 9월 17일 금요일
2021. 9. 17. 오후 9:59, 홍길동 : 안녕하세요
2021. 9. 17. 오후 10:00, 김철수 : 반갑습니다
  • 날짜 구분선(2021년 9월 17일 금요일)과 메시지(2021. 9. 17. 오후 9:59)의 형식이 다릅니다.
  • 날짜 구분선에 시간 정보가 없으므로, KST 자정(00:00)을 기준으로 UTC 변환합니다.

설치

npm install kakaotalk-chat-parser

사용법

기본 사용법

import { readFileSync } from 'node:fs';
import { parse } from 'kakaotalk-chat-parser';

const text = readFileSync('KakaoTalkChats.txt', 'utf-8');
const chatRoom = parse([text]);

console.log(chatRoom.header.title); // 채팅방 이름
console.log(chatRoom.header.savedAt); // 저장 날짜 (Date)
console.log(chatRoom.participants); // 참여자 목록
console.log(chatRoom.messages.length); // 메시지 수

여러 파일 병합 파싱

최근 버전의 카카오톡은 대화를 내보낼 때 하나의 파일이 아니라 여러 파일로 분할합니다. 배열에 순서대로 넣으면 하나의 채팅방으로 합쳐서 파싱합니다.

const texts = [
  readFileSync('Talk_2025.11.14 19:02-1.txt', 'utf-8'),
  readFileSync('Talk_2025.11.14 19:02-2.txt', 'utf-8'),
  readFileSync('Talk_2025.11.14 19:02-3.txt', 'utf-8'),
];
const chatRoom = parse(texts);

미리보기

전체 메시지 목록 없이 헤더, 참여자, 마지막 메시지만 필요한 경우에 사용합니다. 채팅방 목록 화면 등에서 유용합니다. 내부적으로는 전체 메시지를 파싱하지만, 반환 객체에 messagesdates를 포함하지 않아 참조가 해제되므로 GC 후 메모리가 빠르게 안정화됩니다.

const preview = parse(texts, { preview: true });

console.log(preview.lastMessage.sender); // 발신자
console.log(preview.lastMessage.content); // 내용
console.log(preview.lastMessage.type); // 'text', 'photo', 'video' 등

주요 기능

메시지 타입 자동 감지

카카오톡에서 사진이나 동영상을 보내면 내보내기 파일에는 파일명만 남습니다. 이 라이브러리는 확장자를 기반으로 메시지 타입을 자동 분류합니다.

| 타입 | 설명 | | --------- | ------------- | | text | 일반 텍스트 | | photo | 이미지 파일 | | video | 동영상 파일 | | audio | 오디오 파일 | | file | 파일 | | deleted | 삭제된 메시지 | | system | 시스템 메시지 |

message.content; // 'abc123.jpg'
message.type; // 'photo'

참고: 최근 버전의 내보내기 파일에서는 파일명 대신 사진, 동영상 등의 텍스트로 기록되어 확장자 기반 타입 감지가 동작하지 않습니다.

멀티라인 메시지

내보내기 파일에서는 줄바꿈이 포함된 메시지가 여러 줄로 나뉘어 저장됩니다. 다음 타임스탬프가 나타날 때까지의 줄을 하나의 메시지로 합칩니다.

2021. 9. 17. 오후 9:59, 홍길동 : 첫 번째 줄
두 번째 줄
세 번째 줄
message.content; // '첫 번째 줄\n두 번째 줄\n세 번째 줄'

시스템 메시지 구분

초대, 퇴장 등의 시스템 메시지는 sender: null, type: 'system'으로 구분됩니다. 참여자 목록(participants)에는 포함되지 않습니다.

message.type; // 'system'
message.sender; // null
message.content; // '홍길동님이 김철수님을 초대했습니다.'

이모티콘 → 이모지 변환

초기 카카오톡에서는 (부끄), (방긋) 같은 소괄호 형태의 기본 이모티콘을 사용했습니다. convertEmoji 옵션을 켜면 이를 유니코드 이모지로 변환합니다. convertEmoji 옵션을 켜면 이를 유니코드 이모지로 변환합니다. (이모티콘_Muzi and Friends) 같은 스티커 패턴은 매핑 대상이 아니므로 원본 그대로 유지됩니다.

const chatRoom = parse(texts, { convertEmoji: true });

// '고마워(방긋)' → '고마워😄'
// '(썩소)알아(썩소)(썩소)' → '😏알아😏😏'
// '(이모티콘_Muzi and Friends)' → '(이모티콘_Muzi and Friends)' (변환 없음)

시간대 처리

내보내기 파일의 시간은 KST 12시간제(오전/오후)로 기록됩니다. 파싱 시 UTC Date 객체로 변환합니다.

// 원본: "2021. 9. 17. 오후 9:59"
message.timestamp; // 2021-09-17T12:59:00.000Z

예제

examples/ 폴더에 Transformers.js를 활용한 감정 분석 예제가 있습니다.

cd examples
pnpm install
npx tsx sentiment.ts
총 115개 메시지 감정 분석 결과:

기쁨 ████ 14.8% (17개)
슬픔 █ 4.3% (5개)
분노  0.9% (1개)
놀람 ███ 9.6% (11개)
걱정 ██████████████ 45.2% (52개)
감사 ████████ 25.2% (29개)

License

MIT