Get Namespaced ID
Namespaced ID of blocks
Press the F3 key on your keyboard to open the Debug Screen.
The Namespaced ID of the block you are looking at is listed on the right-hand side of the screen:
Namespaced ID of items
Press the F3 and H keys on your keyboard to show Advanced Tooltips.
The Namespaced ID of the item is displayed in the inventory below its name: