How to Create a Custom ID Column in SharePoint List using JSON?

I was recently working on a project where I had to create a custom ID column in a SharePoint list with a specific format like yyyyMMdd-[ID]. But we can’t directly change or customize the default ID column of a SharePoint list.

After researching, I figured out a way to customize the ID column of a SharePoint list using JSON code.

In this article, I’m going to share how you can customize the ID column in a SharePoint list using JSON formatting.

Create a Custom Unique ID Column in SharePoint List

By default, the SharePoint list and library have a pre-defined ID column, which gives a unique ID to each list or library item. This column automatically increments for each item.

For example, if you add a new item to the SharePoint list, it will display the ID as ‘1‘. Similarly, for the following item, display as ‘2‘ and so on.

If you delete an item from the list, the deleted item ID won’t be assigned to the next item.

Create custom unique ID column in SharePoint

You can apply JSON formatting to create a custom ID column in a SharePoint list.

Below are the steps to create a unique ID column in a SharePoint list:

Suppose I have taken a SharePoint list named Event Registration with a couple of columns in it.

Column NameColumn Type
Event nameTitle – Renamed it to Event Name
Event IDSingle line of text
IDDefault column
CreatedDefault column

In this list, I want to customize the Event ID in a specific format like yyyyMMdd-ID [20250404-001].

Customize SharePoint ID column with JSON

Example 1:

  1. Open your SharePoint list, click on the drop-down of a SharePoint column, choose Column settings ->click on Format this column.
How to create a custom ID for lists
  1. It will open the Format view pane; click on the Advanced mode link to insert the code.
How to Create Custom ID Column in SharePoint List
  1. In the Format view, remove the text from the box and add custom JSON code.
    • Paste the code given below.
{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
  "elmType": "div",
  "txtContent": "=toString(getYear([$Created])) + if((getMonth([$Created]) + 1) < 10, '0' + toString(getMonth([$Created]) + 1), toString(getMonth([$Created]) + 1)) + if(getDate([$Created]) < 10, '0' + toString(getDate([$Created])), toString(getDate([$Created]))) + '-' + padStart([$ID], 3, '0')"
}
  1. Click on the Save button to apply the changes.
Creating a custom unique ID in a SharePoint list by JSON
  1. Now, create an item in the Event Registration list.
Customize SharePoint List Item ID
  1. The Event ID will be displayed automatically in a specific format [yyyyMMdd-ID], based on the created date of the list item.
    • Look at the screenshot below:
Create a Custom ID Column in SharePoint List using JSON

Note:

In the above JSON code, you can replace the ID column with any other column, such as the Title or Text column. But the JSON does not support the Number column, as I have tested on my side.

Example 2:

You can also create a custom ID based on the Title column from a SharePoint list, according to your requirement.

In the above code, I will replace the ID with the Title column, then it will show the following output:

{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
  "elmType": "div",
  "txtContent": "=toString(getYear([$Created])) + if((getMonth([$Created]) + 1) < 10, '0' + toString(getMonth([$Created]) + 1), toString(getMonth([$Created]) + 1)) + if(getDate([$Created]) < 10, '0' + toString(getDate([$Created])), toString(getDate([$Created]))) + '-' + padStart([$Title], 4, '0')"
}
Auto Generate Custom ID Value in SharePoint List

This is all you need to know about creating a custom, unique ID column in a SharePoint list.

I hope you found this article interesting and helpful. Let me know about any suggestions in the comments section.

You may also like the following tutorials:

>

Build a High-Performance Project Management Site in SharePoint Online

User registration Power Apps canvas app

DOWNLOAD USER REGISTRATION POWER APPS CANVAS APP

Download a fully functional Power Apps Canvas App (with Power Automate): User Registration App

Power Platform Tutorial FREE PDF Download

FREE Power Platform Tutorial PDF

Download 135 Pages FREE PDF on Microsoft Power Platform Tutorial. Learn Now…