Export Chats in ChatGPT-Team

I managed to put together a quick and crude script to export an individual chat. This is mostly useful to non-devs like me. Paste this in the browser JS console(command + option + C) and hit enter. You should see a text file downloaded. Repeat this with all your chats and don’t forget to refresh the page before running the code. Hope this helps :+1:

// Function to download data as a text file
function download(filename, text) {
var element = document.createElement(‘a’);
element.setAttribute(‘href’, ‘data:text/plain;charset=utf-8,’ + encodeURIComponent(text));
element.setAttribute(‘download’, filename);

element.style.display = 'none';
document.body.appendChild(element);

element.click();

document.body.removeChild(element);

}

// Function to collect chat messages
function collectChatMessages() {
let messages = document.querySelectorAll(‘[data-testid^=“conversation-turn-”]’); // Select conversation turns
let chatHistory = ‘’;

messages.forEach(message => {
    let authorElement = message.querySelector('[data-message-author-role]');
    let textElement = message.querySelector('[data-testid="text-message"]');
    let author = authorElement ? authorElement.innerText : 'Unknown';
    let text = textElement ? textElement.innerText : '';
    chatHistory += `${author}: ${text}\n\n`;
});

return chatHistory;

}

// Collect chat messages and download them
let chatHistory = collectChatMessages();
download(‘chat_history.txt’, chatHistory);

1 Like

Any update on this? It there a possibility to push this topic to devs? How it comes, that I cannot export the chats? I was long time a Plus user, but since 2 month i decided myself to swith to teams. Now i cannot export data? It is really ridicolous. No search possibility on web, no export, how to manage my chats than?

2 Likes

I can’t believe this isn’t a bigger deal for people. It’s really frustrating. I have so many chats! :person_shrugging: I mean, even a search function would be a godsend. I could then find that amazing chat I had a month or two ago and export it.

2 Likes

This place is a ghost town.

This is truly shocking. There is no warning that you will lose all access to your data when you upgrade to teams. I can’t believe I paid extra to lose access to the one feature I cared about. Not surprised that people are switching to other services… They definitely do not totally fail at providing the basics.

Also the fact that its irreversible… What? Hope everyone has been regularly exporting. Also as others have said I am certain this is not GDPR.

1 Like

Has this worked for anyone else here? Is there anymore details someone can provide?