All of the packs from 2012 to 2020 will physically fit in any model S/X from those years. Since 2020, Tesla has continued to produce new packs for these earlier years so you could also come across a pack with a later date code that also fits. In that case, you will need to find a list of part numbers to determine if a 'Model S' pack with a 2022 date code will fit. The cars that came with v1 packs have a slightly different HV rapidmate so you need to use the correct rapidmate ring on the pack to match the car. If you have an older car and want to install a v2 pack, order a HIGH VOLTAGE RAPIDMATE TOP RING - HIGH VOLTAGE BATTERY 2.0(1041311-00-C). It installs on the v2 pack with about 6 screws and cost $4.80. Yes, most parts from Tesla (that aren't HV batteries or drive units) are extremely reasonable once you find them and talk them into selling them to you!
As mentioned in the Basic Architecture tab, there have been several kWh sizes and internal configurations of this pack over the years. Tesla has said that the largest 100kWh packs can't be put in the earlier cars because the suspension can't support the extra weight or perhaps the airbag timing would not be properly calibrated for the added mass. Despite their stance on that, many individuals and 3rd party vendors have done just that. My own car now has a 100kWh pack from a 2017 Model S. I get all the range and the faster charging speeds and I don't notice the extra weight at all (2014 P85D with air suspension). I sold the 85kWh pack documented in this tutorial to cover the cost and I'm very confident the new owner of that pack will have many years of service after all the work that was done to it.
Once the pack is physically installed, you need to go into Service Mode and redeploy the software. Often times, you also need to use Toolbox to configure things to get the car moving - especially if you are putting a battery in a drive motor configuration that didn't ever get that battery. Anecdotally, it sounds like MCU2 is more likely to be able to redeploy the software and get the car moving without Toolbox as long as you have an 'off the shelf' configuration. Either way, if the pack is a different size than the one that was in there, you will need to run the 'post pack install routine' to clear some final errors even if redeploying the software initially gets the pack charging and driving without Toolbox. If you are going this route, do plenty of research first but in short, buying a used (working) battery and installing it in place of your old battery is a very viable path to upgrading or getting your car back on the road and as you can see from this tutorial, very do-able in a home garage!
If you are planning to sell your old battery, take plenty of screenshots from SMT before you take it out. Anyone thinking about buying it will want as much information as they can get.
Although my pack worked after redeploying the firmware and there were no errors on the main console, this error was in the battery menu in service mode. This is simply stating that the car is expecting an 85 pack and sees a 100 pack. The Pack Replacement Routine cleared it up and allowed P100D to show on the dash and also on the phone app. Unfortunately, changing the badge on the trunk lid remains a manual process...
This link from Tesla is useful to understand the syntax of the serial number. In short, the T is for 'Tesla' (the manufacturer) and the next two numbers are the year. The 4th character is a letter representing the month of production. The example below was assembled in October of 2012.