How to colorize Python docstrings to your liking; ex: like strings
Use this technique to find the color you want to set Python docstrings to. The previous default in VSCode was to colorize docstrings the same as strings for most color themes. So, find a string, inspect its color using the Developer: Inspect Editor Tokens and Scopes
tool explained below, and use that as the foreground
color in your user settings.json
file below.
Note: if you do this change and then click the little person icon in the bottom-left of VSCode, and sign in with GitHub (or one of the other sign-in options) and turn on sync, it will apply this change to all instances of VSCode you have, on all computers you have.
You need to add the following to your settings.json
file.
See here for how to open settings.json
from the command palette, and for where it's located on your OS: How can I open Visual Studio Code's 'settings.json' file?. In short, just press Ctrl + Shift + P to open up the command palette, and then type and search for Preferences: Open User Settings (JSON)
. In that user settings JSON file, update the file as explained here:
{
// your other settings here
// new settings to fix the Python docstrings color/formatting:
"workbench.colorTheme": "Monokai", // <<< YOUR COLOR THEME GOES HERE <<<
"editor.tokenColorCustomizations": {
"textMateRules": [
{
"scope": [
// this includes Python docstrings
"string.quoted.docstring",
],
"settings": {
// >>> YOU SET YOUR COLOR YOU WANT FOR PYTHON DOCSTRINGS
// HERE <<<
// Ex: to color docstrings like strings in Monokai
"foreground": "#E6DB74",
// Ex: to color docstrings like comments in Monokai
// "foreground": "#88846F",
}
}
]
},
}
In order to find out what to use for the "foreground"
color in the "settings"
section for the textmate "scope"
of "string.quoted.docstring"
above, use the tokens and scopes inspector in VSCode, as follows:
Press Ctrl + Shift + P to open up the command palette, and then type and search for Developer: Inspect Editor Tokens and Scopes
, as shown here:

Select it. Now, you can click around on different syntax to see the syntax highlighting scope and information, like this. You can see the "string.quoted.docstring.multi.python"
scope in the image below, when I have my cursor on the """
characters at the start of a Python docstring block. And, in the settings.json
file above, I have taken from that the string.quoted.docstring
part. At the bottom of the image below, you can see the foreground
color of #E6DB74
. So, if you like that color for Python docstrings, use it in the settings above. Again, you'll need to do this for your exact color theme, as my color theme is set to Monokai
.

When done inspecting colors, hit Esc to exit the tokens and scopes inspection mode.
Additional details
From my comment on the PR here:
To help people go back:
For anyone wishing to customize your theme to go back to how it was for your syntax highlighter, read my answer here to learn how to do that. It contains info about finding the names and colors of sections you like and how to change the ones you don't:
How to subdue Python docstrings in VSCode in order to look like Sublime Text's Monokai
In my link above, I explain how to use the token and scope inspector, and then I say:
Use this technique to customize other scopes and colors to your liking, or to see what colors and formatting other scopes currently have if you want to copy them.
@starball also has a great answer to this question. With that answer plus the info. and screenshots in my link above, everyone can tweak their syntax highlighters as desired.
By the way, I am the one who created that PR, and VSCode's maintainers are the ones who requested that I massively expand my PR to cover all docstrings, not just Python docstrings, and all syntax highlighters, not just the Monokai syntax highlighter I was using. The idea is to make docstrings, which are used in Python like comments and Doxygen are used in other languages, and which are really more in the category of comments, not strings, be treated by the syntax highlighters the same as comments, not strings. VSCode agreed, and asked me to expand my PR.
But overall, I think though now painful for some, the change is really a benefit to most, and the right default behavior for all going forward.
References
- My answer here, and all references I have at the bottom of that answer: How do I change color of comments in visual studio code?