It's hardly a shining example of livability, but the former Kowloon Walled City purportedly had a population density of over 1.9 million/km2. [0]
More realistically, we can see examples of nice residential neighborhoods in Washington DC ranging from 30,000-100,000+/km2. [1]
[0] https://en.wikipedia.org/wiki/Kowloon_Walled_City
[1] https://ggwash.org/view/42469/what-do-80000-people-in-a-squa...