{"id":15061966,"url":"https://github.com/pustur/whatsapp-chat-parser","last_synced_at":"2025-04-09T06:10:06.301Z","repository":{"id":32842636,"uuid":"144197254","full_name":"Pustur/whatsapp-chat-parser","owner":"Pustur","description":"A package to parse WhatsApp chats with Node.js or in the browser 💬","archived":false,"fork":false,"pushed_at":"2024-09-24T03:53:26.000Z","size":2779,"stargazers_count":176,"open_issues_count":8,"forks_count":35,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-04-09T06:09:58.010Z","etag":null,"topics":["npm-package","parser","whatsapp","whatsapp-chat-parser","whatsapp-parser"],"latest_commit_sha":null,"homepage":"https://whatsapp-chat-parser.netlify.app","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Pustur.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"custom":["https://buymeacoffee.com/Pustur","https://paypal.me/Pustur"]}},"created_at":"2018-08-09T19:52:03.000Z","updated_at":"2025-04-02T18:33:47.000Z","dependencies_parsed_at":"2024-10-23T08:57:23.176Z","dependency_job_id":"1327d788-775b-45a4-8f79-55ec7f8268d6","html_url":"https://github.com/Pustur/whatsapp-chat-parser","commit_stats":{"total_commits":499,"total_committers":5,"mean_commits":99.8,"dds":0.4589178356713427,"last_synced_commit":"57484d5a53cacff39083237825f8cf2df7501129"},"previous_names":[],"tags_count":31,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Pustur%2Fwhatsapp-chat-parser","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Pustur%2Fwhatsapp-chat-parser/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Pustur%2Fwhatsapp-chat-parser/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Pustur%2Fwhatsapp-chat-parser/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Pustur","download_url":"https://codeload.github.com/Pustur/whatsapp-chat-parser/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247987285,"owners_count":21028895,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["npm-package","parser","whatsapp","whatsapp-chat-parser","whatsapp-parser"],"created_at":"2024-09-24T23:28:22.929Z","updated_at":"2025-04-09T06:10:06.271Z","avatar_url":"https://github.com/Pustur.png","language":"TypeScript","funding_links":["https://buymeacoffee.com/Pustur","https://paypal.me/Pustur"],"categories":[],"sub_categories":[],"readme":"# WhatsApp Chat Parser\n\n[![Continuous Integration](https://github.com/Pustur/whatsapp-chat-parser/actions/workflows/ci.yml/badge.svg)](https://github.com/Pustur/whatsapp-chat-parser/actions/workflows/ci.yml)\n[![codecov](https://codecov.io/gh/Pustur/whatsapp-chat-parser/branch/master/graph/badge.svg)](https://codecov.io/gh/Pustur/whatsapp-chat-parser)\n[![npm version](https://img.shields.io/npm/v/whatsapp-chat-parser.svg)](https://www.npmjs.com/package/whatsapp-chat-parser)\n[![minified size](https://img.shields.io/bundlephobia/min/whatsapp-chat-parser.svg)](https://bundlephobia.com/result?p=whatsapp-chat-parser)\n\n\u003e A package to parse WhatsApp chats with Node.js or in the browser 💬\n\n## Important notice\n\n🚨 `v4.0.0` brings some **BREAKING CHANGES**, check out the [release page](https://github.com/Pustur/whatsapp-chat-parser/releases/tag/4.0.0) for more info.\n\n## Introduction\n\nThis library allows you to parse WhatsApp chat logs from text format into javascript objects, enabling you to more easily manipulate the data, create statistics, export it in different formats, etc.\n\nYou can test the package online with this example website:  \n[whatsapp-chat-parser.netlify.app](https://whatsapp-chat-parser.netlify.app/) ([Source code](https://github.com/Pustur/whatsapp-chat-parser-website))\n\n## Install\n\n```\n$ npm install whatsapp-chat-parser\n```\n\n## Usage\n\n### Node\n\n```js\nimport fs from 'node:fs';\nimport * as whatsapp from 'whatsapp-chat-parser';\n\nconst text = fs.readFileSync('path/to/_chat.txt', 'utf8');\nconst messages = whatsapp.parseString(text);\n\nconsole.log(messages);\n```\n\n### Browser\n\nAdd the script to your HTML file (usually just before the closing `\u003c/body\u003e` tag).  \nThen use it in your JavaScript code, the `whatsappChatParser` variable will be globally available.\n\n```html\n\u003cscript src=\"path/to/index.global.js\"\u003e\u003c/script\u003e\n\u003cscript\u003e\n  const messages = whatsappChatParser.parseString(\n    '06/03/2017, 00:45 - Sample User: This is a test message',\n  );\n\n  console.log(messages);\n\u003c/script\u003e\n```\n\nOr with `type=\"module\"` loading the ESM version:\n\n```html\n\u003cscript type=\"module\"\u003e\n  import * as whatsapp from 'path/to/index.js';\n\n  const messages = whatsapp.parseString(\n    '06/03/2017, 00:45 - Sample User: This is a test message',\n  );\n\n  console.log(messages);\n\u003c/script\u003e\n```\n\nYou can also use the [jsDelivr CDN](https://www.jsdelivr.com/package/npm/whatsapp-chat-parser).\n\n```html\n\u003cscript src=\"https://cdn.jsdelivr.net/npm/whatsapp-chat-parser/dist/index.global.js\"\u003e\u003c/script\u003e\n\u003c!-- Or use a specific version --\u003e\n\u003cscript src=\"https://cdn.jsdelivr.net/npm/whatsapp-chat-parser@4.0.2/dist/index.global.js\"\u003e\u003c/script\u003e\n```\n\n## Message structure\n\nThe `messages` variable is an array of objects like this:\n\n```js\n[\n  {\n    date: '2018-06-02T22:45:00.000Z', // Date object\n    author: 'Luke',\n    message: 'Hey how are you?',\n  },\n  {\n    date: '2018-06-02T23:48:00.000Z', // Date object\n    author: 'Joe',\n    message: 'All good, thanks',\n  },\n];\n```\n\nWhen using the option [`parseAttachments`](#options), the message may contain an additional property `attachment`:\n\n```js\n[\n  {\n    date: '2018-06-02T23:50:00.000Z', // Date object\n    author: 'Joe',\n    message: '\u003cattached: 00000042-PHOTO-2020-06-07-15-13-20.jpg\u003e',\n    attachment: {\n      fileName: '00000042-PHOTO-2020-06-07-15-13-20.jpg',\n    },\n  },\n];\n```\n\nIn the case of a system message, the author will be `null`\n\n```js\n[\n  {\n    date: '2018-06-02T22:45:00.000Z', // Date object\n    author: null,\n    message: 'You created group \"Party 🎉\"',\n  },\n];\n```\n\n## API\n\n### parseString(string, [options]) → Array\n\n**string**\n\nType: `string`\n\nRaw string of the WhatsApp conversation\n\n**options**\n\nType: `object`\n\nA configuration object, more details below\n\n## Options\n\n\u003c!-- prettier-ignore-start --\u003e\n| Name | Type | Default | Description |\n| :--- | :--- | :--- | :--- |\n| daysFirst | `Boolean` | `undefined` | Specify if the dates in your log file start with a day (`true`) or a month (`false`). Manually specifying this may improve performance. By default the program will try to infer this information using 3 different methods (look at [`date.ts`](src/date.ts) for the implementation), if all fails it defaults to days first. |\n| parseAttachments | `Boolean` | `false` | Specify if attachments should be parsed. If set to `true`, messages with attachments will include an `attachment` property with information about the attachment. |\n\u003c!-- prettier-ignore-end --\u003e\n\n## A note about messages order\n\nSometimes, likely due to connection issues, WhatsApp exports contain messages that are not chronologically ordered.  \nThis library won't change the order of the messages, but if your application expects a certain order make sure to sort the array of messages accordingly before use.\n\nSee [#247](https://github.com/Pustur/whatsapp-chat-parser/issues/247) for more info.\n\n## How to export WhatsApp chats\n\n- [Android](https://faq.whatsapp.com/android/chats/how-to-save-your-chat-history)\n- [iPhone](https://faq.whatsapp.com/iphone/chats/how-to-back-up-to-icloud/)\n\n## Technologies used\n\n- Language: [TypeScript](https://www.typescriptlang.org/)\n- Testing: [Vitest](https://vitest.dev/)\n- Code formatting: [Prettier](https://prettier.io/)\n- Linting: [ESLint](https://eslint.org/) (with [Airbnb rules](https://www.npmjs.com/package/eslint-config-airbnb-base))\n\n## Requirements\n\n### Node\n\n`Node.js \u003e= 8.0.0`\n\n### Browser\n\nThis package is written in TypeScript with target compilation to ES6.  \nIt should work in all relevant browsers from ~2017 onwards.\n\n## Changelog\n\n[CHANGELOG](CHANGELOG.md)\n\n## License\n\n[MIT](LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpustur%2Fwhatsapp-chat-parser","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpustur%2Fwhatsapp-chat-parser","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpustur%2Fwhatsapp-chat-parser/lists"}