Forum Discussion
How to show folder path for documents in a flat SharePoint library view
- May 21, 2026
Step 1: Create a new column
Go to Library Settings
Click Create Column
Type: Single line of text
Name: Folder Path (or anything)
Step 2: Apply JSON formatting
I am mostly using this JSON in all my projects. The path is hyperlinked and opens the folder in a new tab.{ "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json", "elmType": "a", "attributes": { "href": "=substring([$FileRef],0,lastIndexOf([$FileRef],'/'))", "target": "_blank" }, "style": { "display": "flex", "align-items": "center", "background-color": "#f2f2eb", "border-left": "3px solid #cceced", "border-right": "3px solid #cceced", "padding": "2px 8px", "max-width": "100%", "height": "22px", "text-decoration": "none" }, "children": [ { "elmType": "span", "attributes": { "iconName": "OpenFolderHorizontal" }, "style": { "font-size": "16px", "color": "#003366", "margin-right": "5px", "flex-shrink": "0" } }, { "elmType": "span", "txtContent": "=replace(substring([$FileRef],0,lastIndexOf([$FileRef],'/')),'/sites/YOURSITE/Shared Documents/','')", "style": { "color": "#003366", "white-space": "nowrap", "overflow": "hidden", "text-overflow": "ellipsis", "max-width": "100%" } } ] }Replace this:
/sites/YOURSITE With your actual site path
I am using /sites/YOURSITE with the actual site path so the site name does not show in the path. This makes it easier for users to read.
If you want, you can also include the library name in the path. If you have many nested folders, removing the site part gives more space to clearly show the folder structure.
Step 3: Include this column in flat structure-views
If my post solved your issue or answered your query, please mark it as a Solution and give it a Like.
Step 1: Create a new column
Go to Library Settings
Click Create Column
Type: Single line of text
Name: Folder Path (or anything)
Step 2: Apply JSON formatting
I am mostly using this JSON in all my projects. The path is hyperlinked and opens the folder in a new tab.
{
"$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
"elmType": "a",
"attributes": {
"href": "=substring([$FileRef],0,lastIndexOf([$FileRef],'/'))",
"target": "_blank"
},
"style": {
"display": "flex",
"align-items": "center",
"background-color": "#f2f2eb",
"border-left": "3px solid #cceced",
"border-right": "3px solid #cceced",
"padding": "2px 8px",
"max-width": "100%",
"height": "22px",
"text-decoration": "none"
},
"children": [
{
"elmType": "span",
"attributes": {
"iconName": "OpenFolderHorizontal"
},
"style": {
"font-size": "16px",
"color": "#003366",
"margin-right": "5px",
"flex-shrink": "0"
}
},
{
"elmType": "span",
"txtContent": "=replace(substring([$FileRef],0,lastIndexOf([$FileRef],'/')),'/sites/YOURSITE/Shared Documents/','')",
"style": {
"color": "#003366",
"white-space": "nowrap",
"overflow": "hidden",
"text-overflow": "ellipsis",
"max-width": "100%"
}
}
]
}
Replace this:
/sites/YOURSITE With your actual site path
I am using /sites/YOURSITE with the actual site path so the site name does not show in the path. This makes it easier for users to read.
If you want, you can also include the library name in the path. If you have many nested folders, removing the site part gives more space to clearly show the folder structure.
Step 3: Include this column in flat structure-views
If my post solved your issue or answered your query, please mark it as a Solution and give it a Like.
Thank you for the solution.