Skip to content

Instantly share code, notes, and snippets.

@rhlobo
Created February 19, 2024 03:14
Show Gist options
  • Select an option

  • Save rhlobo/4f7f42058d285d48b96c80e0cf042dd1 to your computer and use it in GitHub Desktop.

Select an option

Save rhlobo/4f7f42058d285d48b96c80e0cf042dd1 to your computer and use it in GitHub Desktop.
Creates an markdown file from an Copilot Chat JSON
# You can export a Copilot Chat session in Visual Studio Code
# to a JSON file via `Ctrl+Shift+P | Chat: Export Session...`
# or by choosing `View > Command Palette | Chat: Export Session...`
# Inspired by https://github.com/Marijn-Bergman/copilot-chat-export-formatter
import sys
import json
def parse(filename):
with open(filename, 'r') as file:
data = json.load(file)
empty = True
with open(f'{filename}.md', 'w') as file:
for request in data.get('requests', []):
if request.get('isCanceled'):
continue
if empty:
title = request.get('followups', [])
if title:
title = title[0].get('title')
if title:
file.write(f"# {title}\n\n")
empty = False
message = request.get('message', {}).get('text')
if not message:
continue
file.write(f"**{message}**\n\n")
responses = request.get('response', [])
for response in responses:
response = response.get('value')
if response:
file.write(f"{response}\n\n")
file.write("-----------------------------------\n\n")
def get_filename():
return sys.argv[1] if len(sys.argv) > 1 else "chat.json"
if __name__ == "__main__":
parse(get_filename())
@uyriq
Copy link

uyriq commented Jun 27, 2024

There i'm using Pwsh instead of Python, the same functionality script, thnks to @rhlobo and @Marijn-Bergman!
https://gist.github.com/uyriq/e18d4adf3facf61e8d73996216d89edd

@FPGArtktic
Copy link

Python and Obsidian script

https://github.com/FPGArtktic/copilot-export-json-to-markdown

Today, with a heart full of the GNU spirit, I'm thrilled to announce something that will surely delight all who value control over their data and the freedom to share knowledge!
We all know those corporate tools that lock our work into their proprietary formats, making migration and true ownership of our content difficult. But now, a light has emerged! I present to you a plugin that is a spark in the darkness of proprietary systems: Copilot Export JSON to Markdown!
Why this matters for Obsidian users!
For those of you who cherish Obsidian as your personal knowledge management powerhouse, this plugin is a game-changer. Obsidian thrives on plain text Markdown files, giving you true ownership and portability of your notes. However, getting your data out of proprietary systems like Copilot and into your Obsidian vault can be a hurdle. This is where Copilot Export JSON to Markdown shines!
It allows you to liberate your valuable interactions and knowledge from Copilot's grasp and seamlessly integrate them into your Obsidian notes. Imagine having all your AI-generated insights, code snippets, and conversational summaries directly accessible and searchable within your own interconnected knowledge graph. This plugin bridges the gap, empowering you to truly own and leverage your data within the open, flexible environment of Obsidian.
I encourage everyone to explore this tool, try it out, and most importantly, support its development! Every contribution, every piece of feedback, every "star" on GitHub brings us closer to a world where software serves humanity, not the other way around.
Remember: Software Freedom is Freedom of Thought! Don't let yourselves be locked in digital cages. Use tools that strengthen your sovereignty.

@uyriq
Copy link

uyriq commented May 24, 2025

Thank you for your work, I will use it and write another thank you :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment