We use functional methods to match the two-Higgs-doublet model with heavy scalars in the nondecoupling regime to the appropriate nonlinear effective field theory, which takes the form of an electroweak chiral Lagrangian (HEFT). The effective Lagrangian is derived to leading order in the chiral counting. This includes the loop induced h→γγ and h→Zγ local terms, which enter at the same chiral order as their counterparts in the Standard Model. An algorithm is presented that allows us to compute the coefficient functions to all orders in h. Some of the all-orders results are given in closed form. The parameter regimes for decoupling, nondecoupling, and alignment scenarios in the effective field theory context and some phenomenological implications are briefly discussed. Published by the American Physical Society 2024