Skip Ribbon Commands
Skip to main content

Quick Launch

Todd Klindt's home page > Todd Klindt's Office 365 Admin Blog > Posts > PowerShell Function to Extract ChatGPT Conversations
May 23
PowerShell Function to Extract ChatGPT Conversations

Hey there, PowerShell enthusiasts and fellow M365 admins! I’ve been tinkering around with a little something I think you'll find helpful, especially if you've been playing around with OpenAI's ChatGPT. I have been and let me tell you, this has been a wild ride.

Meet Format-ChatGPTConversation, it’s a function I wrote that takes your ChatGPT conversation history and formats it into a more digestible output. If you've been in the trenches with ChatGPT, you know that it can be tough to share your conversations with other people. You have to take a bunch of screenshots or just copy out individual parts. Neither of those are any fun. That's where this function comes into play.

Now, you might be thinking, "That's great, but where do I find these ChatGPT conversations?" Good news! You can get the conversations.json file right from the OpenAI chat interface. Just head over to, click on the three dots by your name in the lower left corner, and navigate to "Settings". Once you're in there, click the "Data controls" tab, and voila! There's an "Export" button waiting for you. Clicking that will give you a zip file, and nestled inside it is your conversations.json file.

So what does Format-ChatGPTConversation actually do? Well, it processes this JSON file, extracting relevant conversation details like the title, ID, create time, author, and content. Any system messages or messages without an author are left out. We don't need them muddying up our beautiful output, do we?

Let's talk about how to use this bad boy. You can pipe it to the console, save the formatted output to a text file, pass multiple JSON files through the pipeline, or even group the output by conversation title. Here are a few examples:

Format-ChatGPTConversation -filename "conversations.json"

Format-ChatGPTConversation -filename "conversations.json" | Out-File -Filepath "formatted_conversations.txt"

Get-ChildItem -Path "conversations.json" | Format-ChatGPTConversation

Format-ChatGPTConversation -filename conversations.json | Group-Object -Property Title | Select-Object name, count

And if you're feeling particularly adventurous, you can even select specific conversations and format them in a list:

Format-ChatGPTConversation -filename conversations.json | Where-Object { $_.title -eq "PowerShell Function Advice" } | select author, content | Format-List |


All of those examples are included in the Examples in the function. You can get to them with help Format-ChatGPTConversation -Examples after you’ve downloaded and imported it.

Ain't that a sight for sore eyes? It's like finding a pearl in an oyster. The world of PowerShell and ChatGPT is your oyster, my friends. Go forth and explore.

How do you get this marvel of modern technology? Go to my PowerShell repo on Github and download it. Then use Import-Module to import it into your PowerShell session.

As always, I'd love to hear how you're using this function. Are you finding it helpful? Have you made any tweaks or improvements? Let's have a conversation about our ChatGPT conversations. It's like Inception, but with less Leonardo DiCaprio and more PowerShell.

Until next time,




There are no comments for this post.

Add Comment

Items on this list require content approval. Your submission will not appear in public views until approved by someone with proper rights. More information on content approval.


Body *

Today's date *

Select a date from the calendar.
Please enter today's date so I know you are a real person


Want a message when I reply to your comment? Put your Twitter handle here.