Hi, I’m not sure if this is the place to make a request, but I found myself many times, trying to save my chat to a file, and the only way I found is to select the chat (with the mouse and scrolling all over the text) copy and paste it into a txt file.
I asked chatGPT about this and it says that there is an option to save the chat to a file (with a link to a blog entry, but I cannot add links here), but I never saw it.
I think it would be a nice addition to the chatGPT UI, since it’s a pretty common use case to ask questions to use the answers somewhere else.
I’m using chatGPT pro, always on a PC browser.
Thanks.
They used to have the ability to save to a PDF file, but it looks like they removed the feature. I wonder what the reason was.
Saving all your chats to some kind of archive file may exist yes, but they used to have “Save to PDF” for individual chats which is what most people want for publishing their conversations.
OpenAI probably realized they’ll drive more traffic to their website if a link to the site is the ONLY easy way to share a conversation. As we all know OpenAI is pivoting more towards “profit driven company” and more away from “research company”.
And then add in: remove the ability to continue that shared conversation yourself, based on the prompted behaviors. Now when you share, you get an ad to sign up for ChatGPT plus to create GPTs.
See related discussion about [export-chats-in-chatgpt-team] (which is locked…). Especially see @abhayachandra message there with a console script to download the chat to a file.
I made some improvements to it:
- Adding indication for whether a message is by the user or the model
- Naming the file according to the chat name.
It’s here, in case it could be useful for someone:
// Function to trigger a download of a 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
if (!messages || messages.length === 0) {
console.warn('No chat messages found.');
return 'No messages found.';
}
let chatHistory = '';
messages.forEach(message => {
let authorRole = message.querySelector('[data-message-author-role]')?.getAttribute('data-message-author-role') || 'Unknown';
let textElement = message.querySelector('.text-message');
let text = textElement ? textElement.innerText.trim() : '[No text content]';
let authorLabel = authorRole === 'user' ? 'User' : authorRole === 'assistant' ? 'Model' : 'Unknown';
chatHistory += ${authorLabel}: ${text}\n\n;
});
return chatHistory;
}
// Function to get the active chat name dynamically by background color
function getActiveChatName() {
let chatItems = document.querySelectorAll('.no-draggable.group.rounded-lg'); // All chat items
let activeChatName = 'chat_history';
chatItems.forEach(item => {
let itemStyle = item.getAttribute('style'); // Check background color
if (itemStyle.includes('var(--sidebar-surface-tertiary)')) { // Match the active chat background color
let nameElement = item.querySelector('.relative.grow.overflow-hidden.whitespace-nowrap');
if (nameElement) {
activeChatName = nameElement.getAttribute('title').trim();
}
}
});
return activeChatName.replace(/[<>:"/\\|?*\x00-\x1F]/g, ''); // Sanitize invalid filename characters
}
// Collect chat messages, get the active chat name, and download the file
try {
let chatHistory = collectChatMessages();
let chatName = getActiveChatName();
download(${chatName}.txt, chatHistory);
} catch (error) {
console.error('An error occurred:', error);
}